4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 JavaScript Event Handlers
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
UHTMilk
Junior WebHelper
Junior WebHelper


Joined: 25 Feb 2006
Posts: 5

PostPosted: Fri Apr 18, 2008 10:41 am (16 years ago) Reply with QuoteBack to Top

Hiya,

I would be very grateful if somebody could lend some advice on some keydown event handlers in JavaScript. The code below is used on a site where they need to have the F12 key, across the whole site, show the help file. The keyhandler function does this just fine.

Now on a particular page they need to have the tab key click a button on two textboxes. I've used the keydown event to call the submitScannedEntry to click the button. This works fine in IE but due to the different way the KeyCode is worked out it fails in Mozilla.

Can anybody suggest a way around this? Many thanks in advance.

Code:
function submitScannedEntry() {
   var keyCode = event.keyCode;
   var button = document.getElementById('btnVal')
   if (keyCode == 9){
      button.click();
      return true
   }
   document.onkeydown = keyhandler;
}


document.onkeydown = keyhandler;
function keyhandler(e) {
   var Key = (window.event) ? event.keyCode : e.keyCode;
   if (Key == 123) {
      TB_show('Help','htmlPages/help.html?width=400&height=360', false);
      return false;
   }
}
OfflineView User's ProfileFind all posts by UHTMilkSend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Fri Apr 18, 2008 1:48 pm (16 years ago) Reply with QuoteBack to Top

Forgive me if this is silly (I'm not in the habit of using Javascript keyboard shortcuts), but are function (F1-12) keys meant to be available in Javascript? I was under the impression that function keys are caught by the operating system/the application, and not the web page, in the same way as Ctrl+Alt+Del is caught by Windows and not any application running in Windows...

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
UHTMilk
Junior WebHelper
Junior WebHelper


Joined: 25 Feb 2006
Posts: 5

PostPosted: Fri Apr 18, 2008 1:57 pm (16 years ago) Reply with QuoteBack to Top

I must admit I loathe having to use the F12 key but it's what was requested. As you say they're the function keys so interfering with the default actions is a bit of a design faux pas but on the bright side they originally wanted to override F1...

The function key events can be captured but I haven't found a way to successfully override the default actions.

________________________________
FreakKingdom | FKlog | DumbCustomers
OfflineView User's ProfileFind all posts by UHTMilkSend Personal Message
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.124112 seconds :: 18 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme