detecting capslock key down
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: detecting capslock key down
Unless, like me, you keep 2 BBC Micros running, you had better modify that to
shiftLock happened.
shiftLock happened.
-
- VIP Livecode Opensource Backer
- Posts: 9669
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: detecting capslock key down
The OP wants a message to be sent by virtue of pressing the capsLock key. All the other (very workable) solutions essentially use either a function directly or interrogation of the state of the capsLock key, basically the same thing.
I have never needed this, but am curious if it pans out.
I miss Hermann too.
Craig
I have never needed this, but am curious if it pans out.
I miss Hermann too.
Craig
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: detecting capslock key down
On Linux and Windows one should be able to get a rawKeyCode for the capsLock key.
As far as I know the Macintosh KMAP does not help much.
Currently on a MacMini . . .
BUT if one has this sort of code:
you can discover that the rawKeyCode for capslock is 65509
by pressing a letter key with the capslock DOWN.
Mind you, how the flying fudgebucket you can work out WHEN the capslock is actually pressed down
on a Macintosh escapes me.
BUT, it is a dead-groovy way of getting the rawKeyCodes on a Macintosh for SHIFT, ALT, CTRL, COMMAND and so forth.
THIS does NOT work:
Code: Select all
on rawKeyDown KD
put KD
end rawKeyDown
Currently on a MacMini . . .
BUT if one has this sort of code:
Code: Select all
on rawKeyDown KD
put the keysDown into fld "KEYZDOWN"
end rawKeyDown
by pressing a letter key with the capslock DOWN.
Mind you, how the flying fudgebucket you can work out WHEN the capslock is actually pressed down
on a Macintosh escapes me.
BUT, it is a dead-groovy way of getting the rawKeyCodes on a Macintosh for SHIFT, ALT, CTRL, COMMAND and so forth.
THIS does NOT work:
Code: Select all
on rawKeyDown KD
if KD = 65509 then
put "pressed the capslock" into fld "OOT"
else
put empty into fld "OOT"
end if
end rawKeyDown
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: detecting capslock key down
On a Linux box pressing the capslock key LiveCode picks up a rawKeyCode.
So much for Macintosh.
So much for Macintosh.
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: detecting capslock key down
You could code for this sort of thing:
But it presupposes another key is also being pressed, or another key is being pressed after the capslock key
has been depressed (and is locked down).
IFF the capslock is DOWN (i.e. has already been pressed) then
in a button, for instance
will report 65509
The difference between keysDown and keyDown is that the former one reports a state, while the latter one reports an action.
Code: Select all
if item 2 of the keysDown is 65509 then
--Jump and shout
end if
has been depressed (and is locked down).
IFF the capslock is DOWN (i.e. has already been pressed) then
Code: Select all
put the keysDown
will report 65509
The difference between keysDown and keyDown is that the former one reports a state, while the latter one reports an action.
Last edited by richmond62 on Tue Jul 13, 2021 9:02 am, edited 1 time in total.
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: detecting capslock key down
The problem is that in the Macintosh world pressing the capslock key either does NOT send a rawKey signal
(which seems odd as the processor has to register that the capslock key is being depressed) to the CPU, or
LiveCode doesn't/can't pick a rawKey signal up, this smells odd as LiveCode can detect when the capslock key IS down.
(which seems odd as the processor has to register that the capslock key is being depressed) to the CPU, or
LiveCode doesn't/can't pick a rawKey signal up, this smells odd as LiveCode can detect when the capslock key IS down.
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
-
- VIP Livecode Opensource Backer
- Posts: 9669
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: detecting capslock key down
None of the five "control-style" keys (option, control, shift, command, capsLock) respond to the "rawkeyDown" message. I am not sure I can think of any case where such a response would be useful, since all of those keys are only pertinent in conjunction with another key.which seems odd as the processor has to register that the capslock key is being depressed
For example, if I press the "x" key, I get "120" as the param from "rawKeyDown", whereas, if the either the capsLock or shiftKey is down at that moment, I get "88".
So, as usual, Macintosh reduces clutter.
Craig
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: detecting capslock key down
Not if, for some odd reason you have got it into your head that you want to use the capsLock key
for something other thandoing what a capsLock key usually does.
for something other thandoing what a capsLock key usually does.
And makes it less hackable by those who want to do other things.So, as usual, Macintosh reduces clutter.
-
- VIP Livecode Opensource Backer
- Posts: 9669
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: detecting capslock key down
Richmond.
I am all for creating a new message, or at least rawKeyDown awareness, when one of those five keys are pressed. Certainly this might be used to initiate some personal predefined function. I wonder if there is something deep down that makes such a thing difficult.
Craig
I am all for creating a new message, or at least rawKeyDown awareness, when one of those five keys are pressed. Certainly this might be used to initiate some personal predefined function. I wonder if there is something deep down that makes such a thing difficult.
Craig
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: detecting capslock key down
Aha: next year, at about this time, I shall be presenting online rawKeyDown Awareness ClassesrawKeyDown awareness
complete with navel-gazing, mantras and juju beads.
-
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: detecting capslock key down
The usual reason is that the OS doesn't report it, so LC can't see it either.I wonder if there is something deep down that makes such a thing difficult.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: detecting capslock key down
Indeed.that the OS doesn't report it
So in my favourite "ideal world" [don't worry, I've already got a therapist . . . admittedly she is out in the
garden at the moment teasing lizards and grasshoppers . . . she's extremely level headed: whatever crap
I throw at her she just says 'miaow' or yawns], LiveCode would do one of two things:
1. Bypass MacOS (probably nearly impossible).
2. Somehow lever keysDown . . .
What has to be faced is that MacOS (and Windows, although to a lesser extent) is all about 3 things:
1. Forcing everyone on to the bed of Procrustes . . . https://en.wikipedia.org/wiki/Procrustes
2. Dumbing things down.
3. Not allowing end-users to do much fiddling around round behind the smoke and mirrors.
Oh, as per Procrustes, I am so glad that I grew up before educationalists decided that children might
be traumatised by Greek legends and the original Grimms' Fairy Tales.
-
- Posts: 627
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
Re: detecting capslock key down
I just noticed this thread while looking for something else...
I've used rawKeyDown in conjunction with a capsLock check to do things with the caps lock that have nothing to do with capitalization, which I see similar solutions have been mentioned. I've also used an array of key codes for similar, perhaps even slightly faster, end results.
The problem might have something to do with keyboard scan matrix in the design of most modern computer keyboards, rather than purely for some nefarious motives. This matrix can be rather perplexing and annoying when you want to use an alphanumeric keyboard as a musical instrument to play chords
https://www.musiccrowns.org/viral/evan- ... keyboards/
But it is true that the macOS does not forward certain special key signals such as media keys (play/pause/stop) to Applications. By default the "Play" key launches iTunes for example (although I've seen hacks that override that), or that now defunct FrontRow thing (that was the predecessor to AppleTV)
From that AppleScriptObjC code that was posted, it seems you can get a signal from capsLock key press on macOS but the LC engine doesn't send one. This could be a job for LiveCode Builder FFI!
I've used rawKeyDown in conjunction with a capsLock check to do things with the caps lock that have nothing to do with capitalization, which I see similar solutions have been mentioned. I've also used an array of key codes for similar, perhaps even slightly faster, end results.
The problem might have something to do with keyboard scan matrix in the design of most modern computer keyboards, rather than purely for some nefarious motives. This matrix can be rather perplexing and annoying when you want to use an alphanumeric keyboard as a musical instrument to play chords
https://www.musiccrowns.org/viral/evan- ... keyboards/
But it is true that the macOS does not forward certain special key signals such as media keys (play/pause/stop) to Applications. By default the "Play" key launches iTunes for example (although I've seen hacks that override that), or that now defunct FrontRow thing (that was the predecessor to AppleTV)
From that AppleScriptObjC code that was posted, it seems you can get a signal from capsLock key press on macOS but the LC engine doesn't send one. This could be a job for LiveCode Builder FFI!
Last edited by PaulDaMacMan on Mon Aug 30, 2021 9:25 pm, edited 1 time in total.
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: detecting capslock key down
So, macOS does pick up raw key signals when keys are depressed, it has been programmed NOTthe macOS does not forward certain special key signals
to pass ones on, unlike with Windows and Linux.