Path: csiph.com!aioe.org!.POSTED!not-for-mail From: Joao Rodrigues Newsgroups: comp.lang.javascript Subject: Re: Interrogation of Shift-Key state Date: Sat, 25 Jun 2016 20:34:47 -0300 Organization: Aioe.org NNTP Server Lines: 40 Message-ID: References: NNTP-Posting-Host: dwjxox7hJmNrqeL03+07iQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.javascript:30750 On 06/25/2016 09:59 AM, Janis Papanagnou wrote: > I want to interrogate the boolean state of the Shift-Key (pressed or not). > > I learned it is possible to define event-handlers to control keyup/keydown > events, Yes, it is, but the onkeyup event cannot be cancelled just in case you need to. > then I could adjust some global variable that I can interrogate > where I need that information. But that is bulky and seems unnecessary(?) > complex. A global variable is not a good idea. And you may capture the shift Key pressing whenever needed. > > My application context is a function that is triggered when a button is > pressed. Is there a simple way to just interrogate the Shift-Key status > in that function? Just a simple example using the onkeydown event to prevent Shift key: // HTML -- Joao Rodrigues