Javascript To Put A Hotkey On A Web Page
Join the DZone community and get the full member experience.
Join For Free// description of your code here
This page will fire an event when the key specified in the
variable key1 is pressed.
Cd&
http://www.expertsrt.com
var key1="32";
var x='';
function handler(e)
{
if (document.all) {
var evnt = window.event;
x=evnt.keyCode;
}
else
x=e.charCode;
if (x==key1) location.href='http://www.expertsrt.com';
}
if (!document.all){
window.captureEvents(Event.KEYPRESS);
window.onkeypress=handler;
}
else
{
document.onkeypress = handler;
}
JavaScript
Opinions expressed by DZone contributors are their own.
Comments