|
-
Aug 21st, 2001, 08:09 AM
#1
Thread Starter
Hyperactive Member
advanced keypressing in Internet Explorer
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...
-
Aug 21st, 2001, 07:28 PM
#2
Fanatic Member
For the ALT key it's:
event.altKey
-
Aug 21st, 2001, 07:32 PM
#3
Fanatic Member
Try this:
Code:
<script LANGUAGE = "JavaScript">
function showKey(){
alert(String.fromCharCode(event.keyCode));
}
document.onkeypress = showKey;
</script>
-
Aug 22nd, 2001, 02:39 AM
#4
Thread Starter
Hyperactive Member
So how do I detect if the f.i. "F2" key has been pressed ?
-
Aug 24th, 2001, 01:06 PM
#5
Fanatic Member
try this for the fx keys...
Code:
<script LANGUAGE = "JavaScript">
function showKey(){
event.returnValue = false;
alert(event.keyCode + ' / ' + String.fromCharCode(event.keyCode));
}
document.onkeydown = showKey;
</script>
-
Aug 24th, 2001, 01:07 PM
#6
Fanatic Member
I don't think there's an onkeypress for the function keys...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|