Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4340258
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:19:30+00:00 2026-05-21T11:19:30+00:00

basicly i need my page to respond to left and right arrow keys. so

  • 0

basicly i need my page to respond to left and right arrow keys. so trying to have the body tag trigger an event- got it working in chrome etc, will do nothing in firefox- tried googling and after 50 different results still no dice. anyone got any ideas?

heres what i have that works with chrome-

body tag calls this script

$(document).ready(adjust());

——————the javascript

function adjust(){
 $("body").keydown(function(){arrowKey(event.keyCode);});
}

function arrowKey(k){
alert(k);
    if (k==37)
        alert("Left");
    else if (k==39)
        alert("Right");
    else if (k==32)
        alert("space");
}

ive replaced methods with alerts in the function for testing purpose but i need to be able to call different functions based on which arrow is pressed

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:19:31+00:00Added an answer on May 21, 2026 at 11:19 am

    Actually it works in chrome even without the “event” because event is a keyword in chrome and it is filled with the last triggered event.

    The reason it doesn’t work in firefox is because you should assign the event like this:

    $(document).keydown(function(event){arrowKey(event.keyCode);});
    

    For some reason “body” does not accept the keydown event. Hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basicly I have a bunch of links on a page and I will use
I need to develop an app that is using multithreading. Basicly, I have a
I have a session class that basicly just sets and retrieves session variables, the
Well basicly I have a textview and when the application is created it sets
I'm basicly trying to compare a token(string) with a hex-datatype! Example: #include<stdio.h> #include<string.h> int
My app is basicly and image editor. There is a welcome page which opens
Im have absolutely no experience with .htaccess and i tried something today. I basicly
I'm looking for a free winforms component for an application I'm writing. I basicly
Ok, basicly, I made a script (that one) that makes a .post to a
First of all I am in DESPERATE need of help here PLEASE I will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.