Recent

Author Topic: How to set Capslock or ScrollLock or NumLock under macOS  (Read 1651 times)

Key-Real

  • Full Member
  • ***
  • Posts: 189
How to set Capslock or ScrollLock or NumLock under macOS
« on: September 27, 2022, 03:15:20 pm »
Hi,
how can I toggle Capslock or ScrollLock or NumLock under MacOS?

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2050
  • Fifty shades of code.
    • Delphi & FreePascal
Re: How to set Capslock or ScrollLock or NumLock under macOS
« Reply #1 on: September 27, 2022, 03:33:27 pm »
May I ask for what purpose?
I would be very confused if an application change my System (Keyboard is part of my system)
Maybe there is a better solution if you describe what you aim for?
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Key-Real

  • Full Member
  • ***
  • Posts: 189
Re: How to set Capslock or ScrollLock or NumLock under macOS
« Reply #2 on: September 27, 2022, 07:58:43 pm »
I need to perform an action on pressing the CapsLock Key.

If I press it, the keyboard NSKeyDown event came. The LED on this key light up.
I have a boolean buffer for the whole keyboard. It stores if a key is pressed or not.

He trows me that CapsLock is pressed the whole time(no KeyUp event).

So I need to set the CapsLock off. So he can perform the NSKeyUp.


Code: Pascal  [Select][+][-]
  1.      case myType of
  2.           NSKeyDown : if event.keycode < 256 then keyboard[event.keycode]:=true;
  3.           NSKeyUp : if event.keycode < 256 then keyboard[event.keycode]:=false;
  4.           NSFlagsChanged : if event.keycode < 256 then keyboard[event.keycode]:=not keyboard[event.keycode];
  5.           NSLeftMouseDown: mouseL:=true;
  6.           NSRightMouseDown: mouseR:=true;
  7.           NSLeftMouseUp: mouseL:=false;
  8.           NSRightMouseUp: mouseR:=false;
  9.           NSScrollWheel : mouseWheel:=round(event.deltaY);
  10.       end;
  11.  

Or you knew a better solution?

AND (as we are at this topic)
If I press CapsLock very shortly nothing happens. We waits a little time before raise the event(the LED goes on).
How to get rid of this delay?
« Last Edit: September 27, 2022, 08:25:18 pm by Key-Real »

 

TinyPortal © 2005-2018