Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Get needed behaviour onkeyup

Posted on 2011-03-05
2
Medium Priority
?
596 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
BurnieP earned 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Several part series to implement Internet Explorer 11 Enterprise Mode
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
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 +…

704 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