...

View Full Version : Keystroke Commands



Jazzo
01-18-2009, 03:45 AM
I just want a simple function that redirects you to a different page upon pressing the "x" key on your keyboard. How would I do that? Replies greatly appreciated.

Jazzo

rangana
01-18-2009, 06:15 AM
Might help:
http://www.javascriptkit.com/javatutors/javascriptkey2.shtml
http://www.java2s.com/Tutorial/JavaScript/0280__Document/documentonkeypress.htm

Philip M
01-18-2009, 09:20 AM
Try this:-

<script type = "text/javascript">

document.onkeydown = function(ev) {
var key;
ev = ev || event;
key = ev.keyCode;
if (key == 88) { // x key
window.location = "http://www.adifferentpage.com";
}
}

</script>



"Merely corroborative detail, intended to add artistic verisimilitude to an otherwise bald and unconvincing narrative". W S Gilbert

Jazzo
01-19-2009, 05:27 PM
Thanks guys!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum