Mobile version of this pageToggle Zope's debug mode
Next:
Gmail catching up with the IssueTrackerProduct
Related by category
Wanted: good Javascript for handling key events
keyevents, key events, onkeydown
4th of October 2005
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







Save this page in del.icio.us