king2k5
08-13-2008, 04:23 AM
I have created some hotkeys for fun on my site, and to familiarize myself a little more with JS(im new to it). My hotkeys work, but i want it so that when ctrl is pressed in, the hotkeys arent activated... such as ctrl+a and ctrl+c are still accessible... my code so far:
function checkEnter(e){ //e is event object passed from function invocation
var characterCode //literal character code will be stored in this variable
if(e && e.which){ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else{
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}
if(characterCode == 65){ //Letter A
window.location = "army.php" //submit the form
return false
}
if(characterCode == 72){//Letter H
window.location = "member.php" //submit the form
return false
}
if(characterCode == 77){//Letter M
window.location = "pm.php" //submit the form
return false
}
if(characterCode == 78){//Letter N
window.location = "news.php" //submit the form
return false
}
if(characterCode == 67){//Letter C
window.location = "construc.php" //submit the form
return false
}
if(characterCode == 82){//Letter R
window.location = "research.php" //submit the form
return false
}
if(characterCode == 69){//Letter E
window.location = "explore.php" //submit the form
return false
}
if(characterCode == 80){//Letter P
window.location = "population.php" //submit the form
return false
}
if(characterCode == 75){//Letter K
window.location = "map.php" //submit the form
return false
}
if(characterCode == 83){//Letter S
window.location = "market.php" //submit the form
return false
}
if(characterCode == 66){//Letter B
window.location = "bank.php" //submit the form
return false
}
if(characterCode == 84){//Letter T
window.location = "product.php" //submit the form
return false
}
else{
return true
}
}
<body onKeyDown="checkEnter(event)">
Thank you in advance
function checkEnter(e){ //e is event object passed from function invocation
var characterCode //literal character code will be stored in this variable
if(e && e.which){ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else{
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}
if(characterCode == 65){ //Letter A
window.location = "army.php" //submit the form
return false
}
if(characterCode == 72){//Letter H
window.location = "member.php" //submit the form
return false
}
if(characterCode == 77){//Letter M
window.location = "pm.php" //submit the form
return false
}
if(characterCode == 78){//Letter N
window.location = "news.php" //submit the form
return false
}
if(characterCode == 67){//Letter C
window.location = "construc.php" //submit the form
return false
}
if(characterCode == 82){//Letter R
window.location = "research.php" //submit the form
return false
}
if(characterCode == 69){//Letter E
window.location = "explore.php" //submit the form
return false
}
if(characterCode == 80){//Letter P
window.location = "population.php" //submit the form
return false
}
if(characterCode == 75){//Letter K
window.location = "map.php" //submit the form
return false
}
if(characterCode == 83){//Letter S
window.location = "market.php" //submit the form
return false
}
if(characterCode == 66){//Letter B
window.location = "bank.php" //submit the form
return false
}
if(characterCode == 84){//Letter T
window.location = "product.php" //submit the form
return false
}
else{
return true
}
}
<body onKeyDown="checkEnter(event)">
Thank you in advance