Cross-platform way to get and toggle the Num Lock state lazarus / 31-LCL ---------------------------------------------------------------------- jwdietrich · 2019-06-29 16:56 Is there a cross-platform method for reading and setting the Num Lock state on the numeric keypad available? My application should activate Num Lock on launch or activation and restore the pre-launch state on terminating or when being deactivated. The solution should be cross-platform compatible to Windows and Linux (macOS not necessary, where Num Lock is always on). ---------------------------------------------------------------------- jwdietrich · 2019-07-02 20:49 Well, I think it has reasons that this thread doesn't get a reply. I learned that setting the num lock state requires administrating privileges and isn't part of the userland API, at least in Windows (see e.g. https://stackoverflow.com/questions/25724740/getting-and- setting-numlock-state-in-lazarus). In my opinion, this doesn't make sense, since this is nothing than an issue of the user interface, but this decision has been made long ago. I now changed the design of my app, so that it reads the num lock state and provides a warning if num lock is deactivated. For those who are interested, the following method changes the colour of a small circular shape (NumLockIndicator to be similar to a little LED) to red or green depending on the num lock state: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TMainForm.IndicateNumLockState(Sender: TObject);begin  {$IF DEFINED(LCLcarbon) or DEFINED(LCLCocoa)}    NumLockIndicator.visible := false;  {$ELSE}  if Odd(GetKeyState(VK_NUMLOCK)) then  begin    NumLockIndicator.Brush.Color := clLime;    NumLockIndicator.Hint := 'Num Lock is activated. You can enter numbers via the numeric keypad.';  end  else  begin    NumLockIndicator.Brush.Color := clRed;    NumLockIndicator.Hint := 'Num Lock is deactivated. Numbers cannot be entered via the numeric keypad.';  end;  {$ENDIF}end; This code is inspired by https://forum.lazarus.freepascal.org/index.php?topic=12143.0.