I don’t think you can. The only code I know of to detect the keys returns the F-keys as 0. I think this is good. Otherwise you could potentially lock the person from closing their browser (lock the mouse and keyboard) – the F keys are a last resort sort of.
You’re probably better off to just use ctrl+1, ctrl+2, or something.
This script will allow you to test the codes returned by different key-related events. There are differences in how IE and standards-compliant browsers report the events. Function keys, since the browser may attach internal functions to them, can be problematic.
I was using keypress, but the events and sample you mention do the work.
Thanks very much.
“Function keys, since the browser may attach internal functions to them, can be problematic.”
yes, I Know, my intention is using some of the Fn keys not used mainly.
btw… would be nice trap the key and return nothing to the browser in order to avoid the pressumed action (i.e. F1=BrowserHelp)…
There’s no problem with capturing function key events, but you won’t be able to override the default action - only attach new (additional) functions to that action
Which is why, as you said, you wanna look for keys which are not already used - F12 and F7 are good in moz, safari and IE; F6, F9 and F10 are okay in Opera 8 - but those are just the default setup … whatever you choose, someone somewhere will have it configured to do something else.
Because ultimately, both Windows and Mac can assign almost any key to do almost anything in almost any application.
So … if you do function key scripting you should really add user preferences to let people change the key assignments for themselves. This is what I do with the keyboard navigation hotkey on my menu – http://www.udm4.com/demos/module-keyboard.php
Note also that Opera can’t detect most modifier + key combinations - key events stop being reported if, for example, the ALT key is pressed down.