Key Codes for some keyboard buttons

Discussion in 'Javascript' started by Additya, Jan 22, 2010.

  1. Additya

    Additya Guest

    This tutorial will show you how to get the pressed key in the browser
    window, whether it's Ctrl, Alt, Shift, Page Up, Arrow Up or any other
    key. There's both an Internet Explorer and a Firefox way of doing
    this.

    http://www.ezdia.com/Key_Codes_for_some_keyboard_buttons/Content.do?id=782

    There are several reasons why you may want to capture the key press
    event in a browser window. Perhaps you're making a JavaScript game, or
    a map similar to Google Maps and you want to allow navigation through
    the arrow keys. Getting the pressed key is easy in JavaScript, however
    different browsers use different ways for this
    Additya, Jan 22, 2010
    #1
    1. Advertising

  2. Additya wrote:

    > This tutorial will show you how to get the pressed key in the browser
    > window, whether it's Ctrl, Alt, Shift, Page Up, Arrow Up or any other
    > key. There's both an Internet Explorer and a Firefox way of doing
    > this.
    >
    >

    http://www.ezdia.com/Key_Codes_for_some_keyboard_buttons/Content.do?id=782

    Utter nonsense. Ctrl, Alt, and Shift are detected with the ctrlKey,
    altKey, and shiftKey event properties respectively, `keyCode' is not
    reliable, proprietary event-handler properties are used, Opera or WebKit
    are not considered at all, proprietary control referencing is used, and the
    markup is invalid XHTML or HTML. Oh yes, and code written 2005(!) to
    handle "Internet Explorer and Firefox" is very relevant today, isn't it?

    Of course, none of the half-wits replying there could have possibly
    recognized any of that, only that it would be "working well" (it doesn't)
    or that it "(still) does not work" (of course it doesn't). Blind leading
    the blind.

    For getting a good idea and rather up-to-date information on how hard it
    really is to handle keyboard events cross-DOM/cross-browser, read
    <http://unixpapa.com/js/key.html> instead.


    PointedEars
    --
    Use any version of Microsoft Frontpage to create your site.
    (This won't prevent people from viewing your source, but no one
    will want to steal it.)
    -- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
    Thomas 'PointedEars' Lahn, Jan 22, 2010
    #2
    1. Advertising

  3. Additya

    David Mark Guest

    Thomas 'PointedEars' Lahn wrote:

    [...]

    >
    > For getting a good idea and rather up-to-date information on how hard it
    > really is to handle keyboard events cross-DOM/cross-browser, read
    > <http://unixpapa.com/js/key.html> instead.
    >


    I haven't read the article, but I can tell you it isn't hard to do
    cross-browser keyboard monitoring. I had never had a call for it until
    recently and was pleasantly surprised at how trivial it turned out to
    be. Yes, that script will likely end up in My Library as
    attachKeyboardListeners (or something like that). It is already part of
    the upcoming sequel.
    David Mark, Jan 22, 2010
    #3
  4. David Mark wrote:

    > Thomas 'PointedEars' Lahn wrote:
    >> For getting a good idea and rather up-to-date information on how hard it
    >> really is to handle keyboard events cross-DOM/cross-browser, read
    >> <http://unixpapa.com/js/key.html> instead.

    >
    > I haven't read the article,


    You should.

    > but I can tell you it isn't hard to do cross-browser keyboard monitoring.


    I don't think you are already in a position to make that assessment.

    > I had never had a call for it until recently and was pleasantly surprised
    > at how trivial it turned out to be. Yes, that script will likely end up
    > in My Library as attachKeyboardListeners (or something like that). It is
    > already part of the upcoming sequel.


    I'd be positively surprised if it did as advertised.


    PointedEars
    --
    Prototype.js was written by people who don't know javascript for people
    who don't know javascript. People who don't know javascript are not
    the best source of advice on designing systems that use javascript.
    -- Richard Cornford, cljs, <f806at$ail$1$>
    Thomas 'PointedEars' Lahn, Jan 22, 2010
    #4
  5. Additya

    David Mark Guest

    Thomas 'PointedEars' Lahn wrote:
    > David Mark wrote:
    >
    >> Thomas 'PointedEars' Lahn wrote:
    >>> For getting a good idea and rather up-to-date information on how hard it
    >>> really is to handle keyboard events cross-DOM/cross-browser, read
    >>> <http://unixpapa.com/js/key.html> instead.

    >> I haven't read the article,

    >
    > You should.


    Why? I don't need help with it. :)

    >
    >> but I can tell you it isn't hard to do cross-browser keyboard monitoring.

    >
    > I don't think you are already in a position to make that assessment.


    How would you know?

    >
    >> I had never had a call for it until recently and was pleasantly surprised
    >> at how trivial it turned out to be. Yes, that script will likely end up
    >> in My Library as attachKeyboardListeners (or something like that). It is
    >> already part of the upcoming sequel.

    >
    > I'd be positively surprised if it did as advertised.
    >


    What did I advertise and have I ever failed to surprise?
    David Mark, Jan 22, 2010
    #5
  6. Additya

    Scott Sauyet Guest

    On Jan 22, 11:09 am, David Mark <> wrote:
    > [H]ave I ever failed to surprise?


    Continually. Of course you could shock everyone here by endorsing
    MooTools! :)

    -- Scott
    Scott Sauyet, Jan 22, 2010
    #6
  7. Additya

    David Mark Guest

    Scott Sauyet wrote:
    > On Jan 22, 11:09 am, David Mark <> wrote:
    >> [H]ave I ever failed to surprise?

    >
    > Continually.


    What is obvious to some is often surprising to others.

    > Of course you could shock everyone here by endorsing
    > MooTools! :)
    >


    Now that would be a surprise. Mootools is just another 50-100K of JS
    that is _constantly_ changed by various deluded hacks and occasionally
    crystallizes into something that appears to work in three or four of the
    latest browsers (in their default configurations). How is that worth...
    anything? And it's a _really_ stupid name too. I'm trying to imagine
    corporate IT types dropping that into a conversation. Can't do it.
    David Mark, Jan 22, 2010
    #7
  8. David Mark wrote:

    > Thomas 'PointedEars' Lahn wrote:
    >> David Mark wrote:
    >>> Thomas 'PointedEars' Lahn wrote:
    >>>> For getting a good idea and rather up-to-date information on how hard
    >>>> it really is to handle keyboard events cross-DOM/cross-browser, read
    >>>> <http://unixpapa.com/js/key.html> instead.
    >>> I haven't read the article,

    >> You should.

    >
    > Why? I don't need help with it. :)


    I don't think you ... wait, this thread is at the verge of getting
    recursive. We better end it while we still can.

    >>> but I can tell you it isn't hard to do cross-browser keyboard
    >>> monitoring.

    >> I don't think you are already in a position to make that assessment.

    >
    > How would you know?


    You have not read the article yet.

    >>> I had never had a call for it until recently and was pleasantly
    >>> surprised at how trivial it turned out to be. Yes, that script will
    >>> likely end up in My Library as attachKeyboardListeners (or something
    >>> like that). It is already part of the upcoming sequel.

    >> I'd be positively surprised if it did as advertised.

    >
    > What did I advertise


    That your code/My Library can do "cross-browser keyboard monitoring".

    > and have I ever failed to surprise?


    No; sometimes unfortunately.


    PointedEars
    --
    realism: HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness: XHTML 1.1 as application/xhtml+xml
    -- Bjoern Hoehrmann
    Thomas 'PointedEars' Lahn, Jan 24, 2010
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roger
    Replies:
    1
    Views:
    614
    GreggTB
    May 20, 2005
  2. Greg  --
    Replies:
    4
    Views:
    2,132
  3. Replies:
    2
    Views:
    2,797
    Malcolm
    Aug 20, 2005
  4. Allen
    Replies:
    1
    Views:
    627
    Mark Rae [MVP]
    Dec 3, 2007
  5. Replies:
    3
    Views:
    208
Loading...

Share This Page