Click to See Complete Forum and Search --> : key capture/decode


steeleweed
09-12-2003, 10:49 AM
How can I capture/examine a keypress? Specifially want to detect user hitting F3

Thanks
Ray

Jona
09-12-2003, 10:54 AM
Perhaps a keystroke for F + the number 3, but F3 doesn't have a keycode in JavaScript, taht I know of.

[J]ona

steeleweed
09-12-2003, 10:58 AM
By 'F3' I mean Function Key 3.

Generally, how to I set a variable to the value of the key pressed?
thanks

pyro
09-12-2003, 11:28 AM
You might be interested in http://www.infinitypages.com/research/keycode.htm, though as Jona said, I don't believe you can capture the F3 key...

Jona
09-12-2003, 11:29 AM
I did this in IE, but you'll need more code for Netscape.


<script>
function daKIE() {
var str = "You pressed key #"+event.keyCode+"\n";
alert(String.fromCharCode(event.keyCode));
oDiv.innerHTML=event.keyCode +" = "+ String.fromCharCode(event.keyCode);
alert(str);
}
</script>
</head><body onKeyPress="daKIE()" onMouseDown="daKIE()"><div id="oDiv"></div></body></html>


[J]ona

Jona
09-12-2003, 11:31 AM
Originally posted by pyro
You might be interested in http://www.infinitypages.com/research/keycode.htm, though as Jona said, I don't believe you can capture the F3 key...

Beat me to it. ;)

We're right, though, the F4 key returns "s." :p

[J]ona

Khalid Ali
09-12-2003, 12:00 PM
Here since we are at it, take a look at this page...:D

http://www.webapplikations.com/pages/html_js/document/CompleteKeyEventControl.html

steeleweed
09-12-2003, 01:10 PM
F3 is code 114 but NS 7.1 triggers the Seach-this-page popup and IE opens the Search navframe on the left.

Guess I must first find a way to suppress a browsers's default handling of Function keys...if I can...will let you know if I figure it out.

Thanks to all of you.
Ray

pyro
09-12-2003, 01:17 PM
I highly doubt you will be able to disable the browsers actions for the Function keys. And, even if you could, before doing things like that, you need to think if you should...