I'm writing a corporate intranet-based CMS. I'm trying to capture the onkeydown event to create keyboard shortcuts. Below I'm adding the "ctrl + s" keyboard shortcut to save information.
Code:
function register_hotkeys(e)
{
//alert(e.keyCode + " : " + String.fromCharCode(e.keyCode));
if (e.ctrlKey && e.keyCode == 83) // 83 == s, see if ctrl + s is being pressed
{
document.getElementById('control-panel-form').submit();
}
return false;
}
window.onkeydown = register_hotkeys;
I've googled extensively on creating keyboard shortcuts, but can't seem to find anything that discusses overriding default, built-in shortcuts, such as ctrl+s, as is the case in the example here. When I run this the form submits, but the default "save page as" dialog of Firefox still fires off.
This app is Gecko-only, so I'm looking for a solution that will be compatible with Mozilla, et all. Not too interested in Explorer, but I wouldn't mind hearing about a method that works in Explorer.
Is there a solution, or is this a fruitless quest?
Regards,
Rich
--
[
http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design