Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #30735
| From | Janis Papanagnou <janis_papanagnou@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Interrogation of Shift-Key state |
| Date | 2016-06-25 21:16 +0200 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <nkmlab$1k5j$1@gioia.aioe.org> (permalink) |
| References | <nklv6p$eap$1@gioia.aioe.org> <9a42c75f-3239-4a70-9ce3-7434db0edd00@googlegroups.com> <nkmg47$1b8k$2@gioia.aioe.org> <1652837.7Z3S40VBb9@PointedEars.de> |
On 25.06.2016 20:17, Thomas 'PointedEars' Lahn wrote:
[...]
>
> Why do you want to avoid using the keydown/keyup events?
The samples I saw seemed to have suggested to have to install event handler
functions, "addEventListener()", which would be bulky. (There is also an
aspect why events *might* not be appropriate in my case; please see below
for details on "state" vs. "event" in my case.)
>
>> Or following the 'keyboardEvent()' link on the above 'keyboadEvent' link
>> suggests using a KeyboardEvent() object. My naive tries on the latter
>> (yes, I don't know much of these issues; else I wouldn't ask the question
>> here), e.g.
>>
>> var x = new KeyboardEvent("keypress");
>> if (x.shiftKey) {
>> alert("shift");
>> } else {
>> alert("no shift");
>> }
>>
>> were ineffective, though, so more concrete input would be appreciated.
>
> You should read more carefully. With the above you *create* the keyboard
> event object (and can simulate keypresses by dispatching it to elements).
Okay.
>
> You need to use the keyboard event object that the runtime environment
> creates for you, and dispatches to your event listener, instead.
This is obviously what I don't understand. Which one is it? The function
I want to implement is the following; I press the 'shift' key (the event
is irrelevant _at that stage_), and then I click a button. There's a
onclick function associated with that button, and in that function I want
to interrogate the *state* of the 'shift' key (where the 'shift'-pressed
event is long gone; unless I have installed a handler and memorized the
'shift' keypress-event). To me it seems that the concept of an *event*
handler would not be appropriate here (unless I memorize such events
earlier, through an event listener); rather I wanted a simple *state*
interrogation. From what has been posted thus far I cannot see whether
it is possible at all to interrogate keyboard states. Or whether there's
an event based approach that's as simple as I would have hoped there
exists one. All I need is a boolean function, like keyboard.isShift().
>
> <https://www.w3.org/TR/2015/REC-dom-20151119/#events>
Please be aware that posting links to standards is often not that helpful
to non-experts as it is to experts; the documents rely on knowledge that
someone not familiar with many aspects of javascript just doesn't have.
In other words, they often result in yet more questions than the one asked.
Also, spreading many technical terms like "W3C/WHATWG DOM" may show that
you are an expert, but they don't help someone who is comming here to get
information on a specific, small, and isolated question. Not everyone who
is asking questions has the background of being proficient in Javascript,
nor the goal become an expert. I'm, for example, while proficient in many
aspects of Computer Science and IT, not targetting in getting a thorough
understanding on Javascript. I just hope it is possible to get the piece
of a jigsaw I need to solve the problem that is (still) an obstacle to me.
Janis
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Interrogation of Shift-Key state Janis Papanagnou <janis_papanagnou@hotmail.com> - 2016-06-25 14:59 +0200
Re: Interrogation of Shift-Key state Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-06-25 17:18 +0200
Re: Interrogation of Shift-Key state Janis Papanagnou <janis_papanagnou@hotmail.com> - 2016-06-25 19:47 +0200
Re: Interrogation of Shift-Key state Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-06-25 20:07 +0200
Re: Interrogation of Shift-Key state "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-25 08:51 -0700
Re: Interrogation of Shift-Key state Janis Papanagnou <janis_papanagnou@hotmail.com> - 2016-06-25 19:47 +0200
Re: Interrogation of Shift-Key state Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-06-25 20:17 +0200
Re: Interrogation of Shift-Key state Janis Papanagnou <janis_papanagnou@hotmail.com> - 2016-06-25 21:16 +0200
Re: Interrogation of Shift-Key state Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-06-25 22:33 +0200
Re: Interrogation of Shift-Key state Janis Papanagnou <janis_papanagnou@hotmail.com> - 2016-06-26 00:49 +0200
Re: Interrogation of Shift-Key state Tim Streater <timstreater@greenbee.net> - 2016-06-26 00:06 +0100
Re: Interrogation of Shift-Key state Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-06-26 11:05 +0200
Re: Interrogation of Shift-Key state "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-25 12:17 -0700
Re: Interrogation of Shift-Key state "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-25 12:23 -0700
Re: Interrogation of Shift-Key state Janis Papanagnou <janis_papanagnou@hotmail.com> - 2016-06-26 00:34 +0200
Re: Interrogation of Shift-Key state Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-08-18 20:29 +0200
Re: Interrogation of Shift-Key state "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-08-18 15:17 -0700
Re: Interrogation of Shift-Key state Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-08-20 07:23 +0200
Re: Interrogation of Shift-Key state "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-08-20 00:03 -0700
Re: Interrogation of Shift-Key state Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-08-20 11:48 +0200
Re: Interrogation of Shift-Key state "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-08-25 13:39 -0700
Re: Interrogation of Shift-Key state "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-25 12:20 -0700
Re: Interrogation of Shift-Key state Tim Streater <timstreater@greenbee.net> - 2016-06-25 22:33 +0100
Re: Interrogation of Shift-Key state Janis Papanagnou <janis_papanagnou@hotmail.com> - 2016-06-26 01:18 +0200
Re: Interrogation of Shift-Key state Tim Streater <timstreater@greenbee.net> - 2016-06-26 00:23 +0100
Re: Interrogation of Shift-Key state Janis Papanagnou <janis_papanagnou@hotmail.com> - 2016-06-26 01:37 +0200
Re: Interrogation of Shift-Key state Tim Streater <timstreater@greenbee.net> - 2016-06-26 09:41 +0100
Re: Interrogation of Shift-Key state - workaround Janis Papanagnou <janis_papanagnou@hotmail.com> - 2016-06-26 00:33 +0200
Re: Interrogation of Shift-Key state - workaround "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-06-26 00:53 +0200
Re: Interrogation of Shift-Key state - workaround Janis Papanagnou <janis_papanagnou@hotmail.com> - 2016-06-26 01:31 +0200
Re: Interrogation of Shift-Key state - workaround "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-25 16:52 -0700
Re: Interrogation of Shift-Key state - workaround "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-06-26 01:56 +0200
Re: Interrogation of Shift-Key state - workaround "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-25 16:50 -0700
Re: Interrogation of Shift-Key state Joao Rodrigues <jr@none.com> - 2016-06-25 20:34 -0300
csiph-web