Opt, Cmd, Shift, Caps key handling
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Opt, Cmd, Shift, Caps key handling
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?
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
58 views to date, no takers
-
- VIP Livecode Opensource Backer
- Posts: 9847
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Opt, Cmd, Shift, Caps key handling
Polling the shiftkey, optionkey, etc., messages can provide that.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Opt, Cmd, Shift, Caps key handling
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>.
shiftLock happens
Re: Opt, Cmd, Shift, Caps key handling
Thanks HH, but:
http://stackoverflow.com/questions/9268 ... en-pressed
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. !!
http://stackoverflow.com/questions/9268 ... en-pressed
More details here: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
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. !!
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Opt, Cmd, Shift, Caps key handling
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.
Note.
= Cmdkey and are not distinguishable from keycode in keysdown.
= You may also read the dictionary entry to cmdkey/ctrlkey (cross-platform note).
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
= Cmdkey and are not distinguishable from keycode in keysdown.
= You may also read the dictionary entry to cmdkey/ctrlkey (cross-platform note).
shiftLock happens
Re: Opt, Cmd, Shift, Caps key handling
This was perfect, worked exactly as expected. The 'on idle' helped. Well done, thanks HH