Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #29988

Re: Wait on keyboard

Newsgroups comp.lang.javascript
Date 2016-03-14 11:54 -0700
References (12 earlier) <176191a9-82a7-48b1-affb-e9053c66f4d2@googlegroups.com> <nc4rnk$3kt$1@dont-email.me> <c0352a15-5432-436a-8b29-823c9518050a@googlegroups.com> <nc5fnv$mb4$1@dont-email.me> <95865a2a-5433-446a-a4b3-c6f4c48d1afd@googlegroups.com>
Message-ID <36f7cb82-ce67-461a-888a-0bff96ff1ee4@googlegroups.com> (permalink)
Subject Re: Wait on keyboard
From Scott Sauyet <scott.sauyet@gmail.com>

Show all headers | View raw


jonas.thornvall@gmail.com wrote: 
> Aleksandro wrote:
>> jonas.thornvall@gmail.com wrote:

>>> I wano to call functions on presskey.
>> 
>> And your problem is...?
>>
> That the examples i find want to me to be in a textfield or use 
> another "id" element to reach the keylisteener. There is no global
> keylistener?

You want to listen for any key press anywhere?
 So, if in a small village in Rompin, Malaysia, a young musical 
prodigy destined to write three great symphonies and redefine serious 
music, bringing both hope and despair to the classical music critic 
for the New York Times, destined to write the first song beamed to 
approaching alien spaceship, destined to love and lose six times 
before her tragic death at age 28 -- if she one warm evening in 
mid-June on a toy piano carved from a saman tree presses the key for 
middle-C, you want your code to capture that? 

Oh, are you looking only for computer keys? You want to capture the 
programmer thrilled to hit backspace one final time knowing that his 
system has reached that perfection in which there's nothing left to 
remove, the nuclear technician whose conscience finally wins out over 
her orders as she refuses to press the key for launch, pressing 
instead the one for abort, and the schoolchild -- who doesn't know his 
"keyboarding" class was once called "typing" -- gleefully banging on 
the "G", because that's how his name starts? 

No, you mean on your computer alone? That's a strange notion of 
"global", but never mind. So, then you want to capture the comma you 
agonize over in the email to a potential employer, to capture the 
ever-weaker, ever-despairing mashes on the F1 key as you look 
desperately for help, any help you can find in this unfeeling world, 
and to capture that up-arrow as your retro-game character bravely 
jumps from one falling block to another, and you find you've lost your 
sympathy for his two-dimensional plight? 

Or no, this is only for your browser? You need to capture the hesitant 
typing in the search bar as you stop once again stymied because you 
never remember if it's spelled "seperate" or "separate" and 
"desperate" or "desparate", the graceful way your pinkies spread 
across the diagonal to type CTRL-TAB, the speed at which you can hit 
ALT-Backspace when it turns out that link is actually not safe for 
work, the embarrassment of using CMD-P, and admitting that in the 
digital age, you still rely on dead-tree versions of far too many 
documents. 

You mean this is only for your current tab/window? That's all you care 
about? Why didn't you say so? 


    window.addEventListener("keyup", function (event) {
      // work with event.keyCode, event.shiftKey, event.altKey, etc.
    }, false);

(See `addEventListener` [1] and `KeyboardEvent` [2] for more 
information.) 
  
People have been telling you this for quite some time in this thread. 
If you were willing to get off your high horse and listen to them, you 
would have heard this quite a while ago. 


  [1]: <https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener>
  [2]: <https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent>
  
  -- Scott

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 02:30 -0800
  Re: Wait on keyboard Tim Streater <timstreater@greenbee.net> - 2016-03-11 10:37 +0000
  Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 02:50 -0800
    Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 03:13 -0800
      Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 03:23 -0800
        Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 03:32 -0800
          Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 03:39 -0800
            Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 04:41 -0800
              Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 05:00 -0800
                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 05:43 -0800
      Re: Wait on keyboard Tim Streater <timstreater@greenbee.net> - 2016-03-11 12:13 +0000
  Re: Wait on keyboard "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-03-11 21:52 +0800
    Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 07:29 -0800
  Re: Wait on keyboard Stefan Weiss <krewecherl@gmail.com> - 2016-03-11 17:00 +0100
    Re: Wait on keyboard Stefan Weiss <krewecherl@gmail.com> - 2016-03-11 17:11 +0100
      Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 08:32 -0800
        Re: Wait on keyboard Stefan Weiss <krewecherl@gmail.com> - 2016-03-11 20:20 +0100
      Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 08:55 -0800
        Re: Wait on keyboard Aleksandro <aleksandro@gmx.com> - 2016-03-11 16:30 -0300
          Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 11:46 -0800
            Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 12:22 -0800
              Re: Wait on keyboard Aleksandro <aleksandro@gmx.com> - 2016-03-11 17:25 -0300
                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 12:32 -0800
                Re: Wait on keyboard Aleksandro <aleksandro@gmx.com> - 2016-03-11 17:42 -0300
                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 12:52 -0800
                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-11 12:47 -0800
                Re: Wait on keyboard "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-03-11 18:39 -0800
              Re: Wait on keyboard "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-03-11 18:37 -0800
              Re: Wait on keyboard John Harris <niam@jghnorth.org.uk.invalid> - 2016-03-12 13:16 +0000
                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-12 05:57 -0800
                Re: Wait on keyboard John Harris <niam@jghnorth.org.uk.invalid> - 2016-03-13 10:31 +0000
                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-13 05:55 -0700
                Re: Wait on keyboard "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-13 17:19 +0100
                Re: Wait on keyboard Scott Sauyet <scott.sauyet@gmail.com> - 2016-03-13 13:01 -0700
                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-13 15:19 -0700
                Re: Wait on keyboard Aleksandro <aleksandro@gmx.com> - 2016-03-13 20:08 -0300
                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-13 21:45 -0700
                Re: Wait on keyboard Aleksandro <aleksandro@gmx.com> - 2016-03-14 01:50 -0300
                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-13 22:39 -0700
                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-13 22:46 -0700
                Re: Wait on keyboard Scott Sauyet <scott.sauyet@gmail.com> - 2016-03-14 11:54 -0700
                Re: Wait on keyboard Tim Streater <timstreater@greenbee.net> - 2016-03-14 08:31 +0000
                Re: Wait on keyboard John Harris <niam@jghnorth.org.uk.invalid> - 2016-03-14 10:43 +0000
                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-12 06:04 -0800
                Re: Wait on keyboard "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-12 15:22 +0100
                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-12 07:46 -0800
                Re: Wait on keyboard Tim Streater <timstreater@greenbee.net> - 2016-03-12 15:52 +0000
                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-12 09:25 -0800
                Re: Wait on keyboard Aleksandro <aleksandro@gmx.com> - 2016-03-12 20:16 -0300
                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-12 15:57 -0800
                Re: Wait on keyboard Aleksandro <aleksandro@gmx.com> - 2016-03-12 21:07 -0300
                Re: Wait on keyboard Scott Sauyet <scott.sauyet@gmail.com> - 2016-03-12 21:27 -0800
                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-13 03:08 -0700
                Re: Wait on keyboard "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-03-12 23:30 +0100
                Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-12 06:15 -0800
            Re: Wait on keyboard "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-03-11 18:33 -0800
              Re: Wait on keyboard jonas.thornvall@gmail.com - 2016-03-12 03:01 -0800
    Re: Wait on keyboard "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-03-11 18:30 -0800
    Re: Wait on keyboard Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-12 04:44 +0100
      Re: Wait on keyboard Stefan Weiss <krewecherl@gmail.com> - 2016-03-12 11:21 +0100
        Re: Wait on keyboard Stefan Weiss <krewecherl@gmail.com> - 2016-03-12 11:27 +0100
        Re: Wait on keyboard Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-12 14:44 +0100
    Re: Wait on keyboard "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2016-03-14 18:58 +0800

csiph-web