PDA

Click to See Complete Forum and Search --> : advanced keypressing in Internet Explorer


Inhumanoid
Aug 21st, 2001, 08:09 AM
I've noticed some strange stuff when experimenting with keypressing in IE.
I retrieve ASCICODE using window.event.keyCode (within document.onkeypress(). I can find out if ctrl was pressed using: window.event.ctrlKey.

However when i press a character and the ctrl-key I get a different window.event.keyCode then I would without pressing the ctrl-key.

example: pressing v gives me: 118, pressing v with ctrl gives me: 22 (with window.event.ctrlKey being true).

How can I ever find out which character was pressed ?

Also is it possible to catch alt+character I have not been able to de that, same goes for function keys (F.I. F1), i can't seem to catch them either...

Psyrus
Aug 21st, 2001, 07:28 PM
For the ALT key it's:

event.altKey

Psyrus
Aug 21st, 2001, 07:32 PM
Try this:

<script LANGUAGE = "JavaScript">
function showKey(){
alert(String.fromCharCode(event.keyCode));
}

document.onkeypress = showKey;

</script>

Inhumanoid
Aug 22nd, 2001, 02:39 AM
So how do I detect if the f.i. "F2" key has been pressed ?

Psyrus
Aug 24th, 2001, 01:06 PM
try this for the fx keys...

<script LANGUAGE = "JavaScript">
function showKey(){
event.returnValue = false;
alert(event.keyCode + ' / ' + String.fromCharCode(event.keyCode));
}

document.onkeydown = showKey;

</script>

Psyrus
Aug 24th, 2001, 01:07 PM
I don't think there's an onkeypress for the function keys...