PDA

View Full Version : keycode event


Xproterg
01-11-2006, 06:40 PM
if (document.all) { e = window.event; }
if (document.layers) { pressedKey = e.which; }
if (document.all) { pressedKey = e.keyCode; }
if(pressedKey != 206){

I posted the code above to show you the event. Does there exist a piece of code that will take the input keycode and reverse it to give you the corresponding key?

A1ien51
01-11-2006, 06:47 PM
function handleKeyPress(evt) {
var keyCode = (window.event)?event.keyCode:evt.which;
alert(keyCode);
return true;
}
document.onkeydown= handleKeyPress


Your code is a little wrong on the detection....

Eric

2reikis
01-11-2006, 10:00 PM
Or to get a string from the code....

alert("key pressed is:"+String.fromCharCode(keyCode));

Xproterg
01-11-2006, 10:25 PM
Thanks