Solved

Get needed behaviour onkeyup

Posted on 2011-03-05
2
587 Views
Last Modified: 2012-05-11
Hello,

This is the code I use to

<script type="text/javascript">
function ControlKey(event) {
        
    switch (event.keyCode)
    {
    case 9:
        if(active_id!='') {
        Edit();
        }
        break;
    case 13:    
        break;
    }
}

  $(document).ready(function () {
     $(window).keyup(function(event) {
     ControlKey(event);
     });
});

Open in new window


Function Edit() is online editor, so it transforms table cell to select form. It works.

But the problem is that when I press tab (being inside of select) browser (Firefox) first gives focus to address , then to the next focusable element .
Only when (after few tabs) it comes back to the same select form and I press tab again I get function Edit() working.
So it looks like browser fires own event on tab and ignoring my custom.

An idea how to solve it?
0
Comment
Question by:APRESTOUS
2 Comments
 
LVL 16

Accepted Solution

by:
BurnieP earned 500 total points
ID: 35043556
Hi,

Instead of using window you should try setting it at the document level.  Also, with keys like Tab, you should try the keyPress event instead.

  $(document).ready(function () {
     $(document).keypress(function(event) {
     ControlKey(event);
  });

You can try this and see if you get bettter results.
0
 

Author Closing Comment

by:APRESTOUS
ID: 35046121
Yes, it did it.
Probably clue was is "keypress" instead of "keyup"
Thank you!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now