Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #30744
| From | Janis Papanagnou <janis_papanagnou@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Interrogation of Shift-Key state |
| Date | 2016-06-26 00:49 +0200 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <nkn1q4$856$1@gioia.aioe.org> (permalink) |
| References | (1 earlier) <9a42c75f-3239-4a70-9ce3-7434db0edd00@googlegroups.com> <nkmg47$1b8k$2@gioia.aioe.org> <1652837.7Z3S40VBb9@PointedEars.de> <nkmlab$1k5j$1@gioia.aioe.org> <1772276.oMNUckLgyt@PointedEars.de> |
On 25.06.2016 22:33, Thomas 'PointedEars' Lahn wrote:
> Janis Papanagnou wrote:
>
>> which would be bulky.
>
> What is that supposed to mean?
That is suposed to mean that comparably a lot code is required as opposed
to a static state interrogation. To be more concrete, the workaround that
at least seems to work in my context is
var shiftState = false;
function keyEvent (ev) { shiftState = ev.shiftKey; }
document.addEventListener("keydown", keyEvent);
document.addEventListener("keyup", keyEvent);
...
function f () { if (shiftState) ... }
as opposed to a (desired, but obviously non-existing)
function f () { if (keyboard.shiftPressed()) ... }
Given that I'm not sure that the shift key event will be correctly handled
in other environments as well the former might not only be bulky but also
non-portable. (Portability is no requirement, though, but it would be nice
to have a wider support).
>
>> (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.)
>
> Events are appropriate in your case and the only way to solve your problem.
So that finally answers my questions (Subject: Interrogation of Shift-Key
state); I learned that the keyboard state can not be interrogated directly.
Thanks.
>
>>> 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?
>
> Pardon?
You said "the keyboard event object"; I didn't understand which [existing]
object that actually is.
>
>> 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,
>
> What you call “a onclick function” is an event listener for the “click”
> event on that button to which applies what I said before.
Obviously I can't put the ties together. :-(
I have
<input type="button" ... onclick="f(10)">
and the function
function f(n)
{
if (SHIFTSTATE) { alert("shift"); } else { alert("no shift"); }
...
}
I still don't see how to access the "event" here to define SHIFTSTATE.
>
>> 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).
>
> Apparently you have not realized yet that the “shiftKey” property is not
> only available on keyboard events.
For my purpose it's in the first place irrelevant; all I wanted to know is
whether there's a simple keyboard shift-key state interrogation or not.[*]
Janis
[*] There was a simple "Yes." statement of yours in your first posting; yet
it seems that this well known sociopathic short reply was wrong, given what
I read in subsequent replies. Anyway; plain answers like "yes" or "no" without
concrete substance are (while "logically" correct) anyway completely useless
as are all the other insinuations, like not having read text behind links,
like not having tried out anything, not knowing how to post questions, etc.
This behaviour of yours is well known. For years. I guess this won't change.
Anyway. Good luck.
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