Solved

Get needed behaviour onkeyup

Posted on 2011-03-05
2
588 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

919 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