Path: csiph.com!1.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: "Christoph M. Becker" Newsgroups: comp.lang.javascript Subject: Re: Interrogation of Shift-Key state - workaround Date: Sun, 26 Jun 2016 00:53:54 +0200 Organization: solani.org Lines: 29 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: solani.org 1466895227 1323 eJwFwYEBACAEBMCVEv8YJ8X+I3QHpfC6ETQM5gmkjnZkJxyltqnEeVNVmL0kod7t4nd12AcYRBDY (25 Jun 2016 22:53:47 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sat, 25 Jun 2016 22:53:47 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 X-User-ID: eJwNw4ENwDAIA7CX2CBJOafQ8f8JnSXD+bAVBAODsdNKq4K0o4WKnPXSEqBt9mFF+X/GbfG7FxsRCA== In-Reply-To: Cancel-Lock: sha1:Z5CuqeKujfhcsqvOTcYcPQfUaqk= X-NNTP-Posting-Host: eJwNxcERwDAIA7CVEopxGcch5/1HaPURnto1zEIlDHPdASh6TgiYKzlKr7tSh4vx5+nemtD5ADI5EhY= Xref: csiph.com comp.lang.javascript:30745 On 26.06.2016 at 00:33, Janis Papanagnou wrote: > On 25.06.2016 14:59, Janis Papanagnou wrote: >> I want to interrogate the boolean state of the Shift-Key (pressed or not). > > In my system context (Linux) the workaround that I wanted to avoid works as > expected at least. So for folks who want to implement such functionality > and are interested in my workaround I post the code skeleton for reference. > > […] In another reply you've mentioned that you're actually being interested in interogating whether a shift key is pressed while a mouse button is clicked. For that purpose you don't need that workaround, but rather can ask for whether a shift key is pressed in the click event handler (as has been pointed out by others already[1]): someElement.addEventListener("click", function (event) { if (event.shiftKey) { alert("shift key pressed while mouse button clicked"); } } [1] Which have been actually more useful replies than this one, even though that might not appear so to you. :) -- Christoph M. Becker