Page 1 of 1

Opt, Cmd, Shift, Caps key handling

Posted: Sun Sep 25, 2016 4:50 pm
by seaniepie
Hi all,
I need to make a way to handle messages from Opt, Cmd, Shift and CapsLock key presses without having to wait for other keys to be pressed (which is easy for example using either the optkeydown message or the RawKeyDown message). I had been hoping the Infinite LiveCode project which could have made it possible would have been finished by now but no such luck. Is there any other way that people have made it possible to add in this functionality?

Re: Opt, Cmd, Shift, Caps key handling

Posted: Sat Oct 01, 2016 6:39 pm
by seaniepie
58 views to date, no takers :roll:

Re: Opt, Cmd, Shift, Caps key handling

Posted: Sat Oct 01, 2016 7:10 pm
by FourthWorld
Polling the shiftkey, optionkey, etc., messages can provide that.

Re: Opt, Cmd, Shift, Caps key handling

Posted: Tue Nov 01, 2016 4:30 am
by [-hh]
You may be interested in this note from the dictionary (rawkeyDown)
Cross-platform note: On Mac OS systems, no message is sent when a modifier key (Shift, Option, Control, or Command) is pressed, unless another key is pressed along with the modifier key. Mouse wheels do not send a rawKeyDown message on Mac OS systems>.

Re: Opt, Cmd, Shift, Caps key handling

Posted: Fri Jan 20, 2017 5:38 pm
by seaniepie
Thanks HH, but:
http://stackoverflow.com/questions/9268 ... en-pressed
From the Cocoa event handling guide:
The flagsChanged: method can be useful for detecting the pressing of modifier keys without any other key being pressed simultaneously. For example, if the user presses the Option key by itself, your responder object can detect this in its implementation of flagsChanged
:.
More details here:
https://developer.apple.com/library/con ... vents.html

When Infinite pulls its thumb out of its butt I can push on with this and more. They promised for Summer 2016. !!

Re: Opt, Cmd, Shift, Caps key handling

Posted: Fri Jan 20, 2017 8:34 pm
by [-hh]
Sorry, I was wrong. "MacOS" means in the dictionary the old MacOS 9.
You may try your luck with the following, as Richard said above, works here on MacOS 10.12.

Code: Select all

on idle
   put "option: " & the optionkey &cr& \
         "command: " & the cmdkey &cr& \
         "shift: " & the shiftkey &cr& \
         "capslock: " & the capslockkey &cr& \
         "control: " & the ctrlkey into ks
   put the keysdown &cr& ks into fld 1
end idle
Note.
= Cmdkey and are not distinguishable from keycode in keysdown.
= You may also read the dictionary entry to cmdkey/ctrlkey (cross-platform note).

Re: Opt, Cmd, Shift, Caps key handling

Posted: Fri Feb 10, 2017 6:38 pm
by seaniepie
This was perfect, worked exactly as expected. The 'on idle' helped. Well done, thanks HH