...

View Full Version : OnKeyDown go to a url?



davidknag
01-31-2011, 07:57 PM
I want to code a script that when you press the right arrow key, it goes to a page.

any ideas?

gusblake
01-31-2011, 09:54 PM
Yeah something like this:



window.onkeydown=function(e) {
if(e.keyCode==39) {
window.location.href="http://url/";
}
}

Philip M
01-31-2011, 10:04 PM
Cross-browser version:-


<script type = "text/javascript">

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

}
</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum