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 920583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:44:20+00:00 2026-05-15T18:44:20+00:00

I am wondering if there was a possibility to navigate with arrow keys through

  • 0

I am wondering if there was a possibility to navigate with arrow keys through a table I created with JS(using jQuery)? I mean jumping from cell to cell…The script is for Greasemonkey.

The alert, however, works. I just got no idea how to make it well-functioning.

$(document).keydown(function(e){
    if (e.keyCode == 37) { 
       alert( "left pressed " );
       return false;
    }
    if (e.keyCode == 38) { 
       alert( "up pressed " );
       return false;
    }
    if (e.keyCode == 39) { 
       alert( "right pressed " );
       return false;
    }
    if (e.keyCode == 40) { 
       alert( "down pressed " );
       return false;
    }
});
;

Any hint or whatever is much appreciated.
Thanks in advance,
Faili

Update

It seems like I explained myself wrong. Give me another try:
Demo

This one may give you an idea of what I wanted. After selecting one input-field a navigation with arrow keys is possible.
My problem is that I just can't realise it via GM and jQuery. Any idea?

Thanks again for your time and effort.

Finally it was like:


function myTest_analysis1(e,leftkey,up,right,down){
    myTest(e,'','','field_analysis2','field_communication1')

function myTest(e,leftkey,up,right,down)
{
  if (!e) e=window.event;
  var selectArrowKey;
  switch(e.keyCode)
  {
  case 37:
    // Key left.
    selectArrowKey = leftkey;
    break;
  case 38:
    // Key up.
    selectArrowKey = up;
    break;
  case 39:
    // Key right.
    selectArrowKey = right;
    break;
  case 40:
    // Key down.
    selectArrowKey = down;
    break;
  }
  if (!selectArrowKey) return;  
  var controls = window.document.getElementById(selectArrowKey);
  if (!controls) return;
  controls.focus();
}
}
 $('#field_analysis1').keydown (myTest_analysis1);

That's how it worked out for me. I bet there is a smarter solution, but I couldn't figure it out right now.

Thank you sooo much for your time and effort.

  • 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-15T18:44:21+00:00Added an answer on May 15, 2026 at 6:44 pm

    You should be able to focus the various cells, I will put an example together using .focus()

    Here is the example.

    Please bear in mind that…

    a) There is nothing in this example to stop you from going out of bounds, you would need to restrict the values of currentRow and currentCell to the number of cells and prevent them from going below 0.

    b) At the moment, there is no code to remove the green text, which is what I’ve used to show the current focus. This means a green trail is left behind.

    You could solve both of the above fairly easily, but they would make the example more complicated…

        var currentRow = 0;
        var currentCell = 0;
    
        function ChangeCurrentCell() {
            var tableRow = document.getElementsByTagName("tr")[currentRow];
            var tableCell = tableRow.childNodes[currentCell];
            tableCell.focus();
            tableCell.style.color = "Green";
        }
        ChangeCurrentCell();
    
        $(document).keydown(function(e){
            if (e.keyCode == 37) { 
               currentCell--;
               ChangeCurrentCell();
               return false;
            }
            if (e.keyCode == 38) { 
               currentRow--;
               ChangeCurrentCell();
               return false;
            }
            if (e.keyCode == 39) { 
               currentCell++;
               ChangeCurrentCell();
               return false;
            }
            if (e.keyCode == 40) { 
               currentRow++;
               ChangeCurrentCell();
               return false;
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering, is there any possibility to create a table where i have
I am wondering if there is a possibility to put spring beans from a
I was wondering if there is any possibility through which one can reset the
I just wondering if there is a possibility to insert into the database two
Wondering if there is any way to get the lambda expressions that result from
I was wondering if there is a possibility to catch errors like this in
I'm looking at the possibility of using the tool SQLMetal . I was wondering
I am wondering if there is any potential security risk from the following code.
I am just wondering if there is a possibility that my program can add/remove
I'm wondering if there's a possibility to have access to any of developer version

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.