Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Javascript To Put A Hotkey On A Web Page

DZone's Guide to

Javascript To Put A Hotkey On A Web Page

·
Free Resource
// 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;
} 
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}