detecting capslock key down

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: detecting capslock key down

Post by richmond62 » Sun Aug 29, 2021 7:59 pm


PaulDaMacMan
Posts: 617
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: detecting capslock key down

Post by PaulDaMacMan » Mon Aug 30, 2021 1:48 pm

richmond62 wrote:
Sun Aug 29, 2021 7:26 pm
the macOS does not forward certain special key signals
So, macOS does pick up raw key signals when keys are depressed, it has been programmed NOT
to pass ones on, unlike with Windows and Linux.
As far as old OSX /macOS (reading up on the latest it seems iOS/mac Catalyst might be different) I believe that is correct (probably more correct to say it has *NOT been programmed to) as a default fro certain special keys. I'm trying to find where I read that on Apple's dev site in the documentation for Event Handling, NSEvent or NSResponder maybe. That was true by default for certain special keys like the media keys Play/Pause/Stop/etc. Eject and the Power Button (which brings up the Finder shutdown dialog). That does not mean that a driver level thing like ControllerMate that comes with a Kernel Extension, or maybe LCB HIDAPI library (shameless plug) that can poll, can't still respond.
Where there's a will there's a way:
https://stackoverflow.com/questions/388 ... -pause-key
https://developer.apple.com/library/arc ... index.html

I'm not sure that CapsLock, that modifies other keys, actually sends it's own key up/down signals (I think it doesn't), but you can certainly check it's state.
Last edited by PaulDaMacMan on Mon Aug 30, 2021 9:34 pm, edited 1 time in total.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

PaulDaMacMan
Posts: 617
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: detecting capslock key down

Post by PaulDaMacMan » Mon Aug 30, 2021 6:15 pm

richmond62 wrote:
Sun Aug 29, 2021 7:59 pm
Um:

https://www.w3schools.com/howto/howto_j ... pslock.asp
-

SShot 2021-08-29 at 21.59.27.png
Ummm, that looks like JavaScript which is interpreted inside of a runloop of something else (a WebBrowser typically), which could be doing it's own polling of the capsLock state. As you can see here in the link from that page, macOS' Safari browser is shown as compatible and that JS seems to require some other key/mouse event to trigger it:
https://www.w3schools.com/jsref/event_m ... rstate.asp

You can do that in LiveCode Script on macOS too and I know this because I've done it.
Here I have a loop checking the keysDown and capsLock (which I had set to shift notes down by a fifth):
https://www.youtube.com/watch?v=s_knX8mJg1c
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

Post Reply

Return to “Talking LiveCode”