Hello,
I'm trying to associate different functions to different keys to create keyboard shortcuts for my online application. I will create a help page to share these keyboard shortcuts with my users.
My problem is, I'm trying to associate the key "t" to toggle the screen. Unfortunately, it seems whenever the user refreshes the page in Firefox using the F5 button, the browser seems to simulate pressing the "t" key after the page reloads. I'm wondering if there is some problem with my code, or some way to have Firefox not do this. My other keyboard shortcuts work just fine.
<script>
function keyboard(e){
var code;
if(!e) var e = window.event;
if(e.keyCode) code = e.keyCode;
else if(e.which) code = e.which;
var key = String.fromCharCode(code).toLowerCase();
if(key=="l"){alert("L pressed");}
else if(key=="t"){alert("T pressed");}
else if(key=="w"){alert("W pressed");}
}
window.onkeypress = keyboard;
</script>