Page 3 of 3

Re: detecting capslock key down

Posted: Sun Aug 29, 2021 7:59 pm
by richmond62

Re: detecting capslock key down

Posted: Mon Aug 30, 2021 1:48 pm
by PaulDaMacMan
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.

Re: detecting capslock key down

Posted: Mon Aug 30, 2021 6:15 pm
by PaulDaMacMan
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