I've searched and searched but can't find anything that is good enough. What I'm after is some Javascript/ECMAScript code that let's me control what keys the user presses on a particular page. One page that does this well is Gmail but their code is so damn hard to debug because of all the "obfuscation".

So, do you know any pages where they've really got keyevents going with javascript? I mean for the whole page, not just a simple onkeydown on a form input. The only stuff I've found either doesn't work in IE or doesn't work at all in Mozilla.

I know that it's considered bad usability to fiddle with the keys because it can break something native to the browser but I know what I'm doing and Gmail as an example that it is possible.

UPDATE

I've found something that works now. At least in Firefox and MS IE 6. It uses the onkeypress event like this:


function body_onkeypress(evt){
   if (!keyboard_shortcuts_enabled) return;
   function S(k) { return String.fromCharCode(k); }
   if (window.event) key=window.event.keyCode;
   else key=evt.which;
   var s = S(key);
   // then do something with 's'
}
document.onkeypress = body_onkeypress

Comments

Your email will never ever be published.

Previous:
Toggle Zope's debug mode October 1, 2005 Zope
Next:
Gmail catching up with the IssueTrackerProduct October 4, 2005 Web development
Related by category:
Fastest way to find out if a file exists in S3 (with boto3) June 16, 2017 Web development
Be very careful with your add_header in Nginx! You might make your site insecure February 11, 2018 Web development
<datalist> looks great on mobile devices August 28, 2020 Web development
How to have default/initial values in a Django form that is bound and rendered January 10, 2020 Web development