PDA

View Full Version : Can I use an F-key as a trigger or link?



marker2001
12-14-2007, 04:42 AM
I'm creating an application and was wondering if I can assign links to F-keys?

Say I press F1 and it redirects the browser to google.com or
press F2 and it goes to msn.com

Not exactly my purpose but you get the idea.

Can I do this with javaScript? :confused:
Can I do this at all?

I can't find any reference in google at all. Perhaps that's my answer.

TIA,
- Mark

BYK
12-14-2007, 05:01 AM
You probably can not assign something to F1 since it is strictly reserved for help, but you should be able to functions/responses to most of the remaining F-Keys using their key codes with an onkeydown or onkeyup event.

djr33
12-14-2007, 05:05 AM
May be possible, though I'm not quite sure how.
However, it isn't a very good idea because this isn't very accessible. For mac users, the function keys are there but actually have some use, and some browsers (or other apps running in the background) may have some function (like F1 can be help). It will likely also not be fully cross-browser compatible. Also, laptops have compressed keyboards, usually with functions associated with those keys and the "F" values actually hidden, behind the "fn" key (which acts like shift for secondary values).

BYK
12-14-2007, 03:00 PM
By the way you can gather the key codes for F-Keys buy assigning a function to onkeydown/onkeyup which alerts the keycode ;)

jscheuer1
12-14-2007, 06:25 PM
Don't use the F word, er key.

Twey
12-14-2007, 06:37 PM
As djr33 says. If it's captured by something else, chances are your app will never even receive the event.

jscheuer1
12-14-2007, 06:50 PM
It's not nice to attempt to override the user's preferences for keys. It can lead to loss of accessibility for your page.

marker2001
12-14-2007, 08:32 PM
Got it.
Probably not a good idea to use the F-word . . . er, keys.

Thanks guys!!

BYK
12-14-2007, 09:25 PM
A customizable hot-key system might come handy if you still want to use keys or key combos :)

jscheuer1
12-14-2007, 11:44 PM
A customizable hot-key system might come handy if you still want to use keys or key combos :)

Even that is a tricky proposition. Every key and key combination is potentially reserved by any given user. In those cases, the design will fail.

Even though there is code and are attributes/tags to detect keys and key combinations and to react to them, it isn't a very good approach to web design because the user will often either be overriding them without even realizing it, or become frustrated with them if they override their configured or accustomed key and key combination shortcuts.

Links and the events of link and/or other tags provide all the flexibility any designer could require for users to activate dynamic content or page changes.

Twey
12-14-2007, 11:47 PM
Links and the events of link and/or other tags provide all the flexibility any designer could require for users to activate dynamic content or page changes.You can even use the "accesskey" to specify a keyboard shortcut.

BYK
12-15-2007, 06:13 AM
I'm creating an application

He/She told that it is going to be an application, that's why I kept the hot-key idea, otherwise I probably will never use niether suggest a hot-key system in a normal web site ;)