Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Can I use an F-key as a trigger or link?

  1. #1
    Join Date
    Oct 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Can I use an F-key as a trigger or link?

    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?
    Can I do this at all?

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

    TIA,
    - Mark

  2. #2
    Join Date
    Dec 2007
    Location
    Ankara, Turkey
    Posts
    160
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default

    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.

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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).
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Dec 2007
    Location
    Ankara, Turkey
    Posts
    160
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default

    By the way you can gather the key codes for F-Keys buy assigning a function to onkeydown/onkeyup which alerts the keycode

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Don't use the F word, er key.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    As djr33 says. If it's captured by something else, chances are your app will never even receive the event.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It's not nice to attempt to override the user's preferences for keys. It can lead to loss of accessibility for your page.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #8
    Join Date
    Oct 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Got it.
    Probably not a good idea to use the F-word . . . er, keys.

    Thanks guys!!

  9. #9
    Join Date
    Dec 2007
    Location
    Ankara, Turkey
    Posts
    160
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default

    A customizable hot-key system might come handy if you still want to use keys or key combos

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by BYK View Post
    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •