w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Is there any way, in Python, to programmatically change the CAPS LOCK/NUM LOCK/SCROLL LOCK states on a hidraw device

Using library at Jakub Wilk's library at http://jwilk.net/software/python-keyboardleds, it is pretty simple:

lk = LedKit('/dev/input/event1')
lk.num_lock.reset()
lk.caps_lock.reset()

The trick is to determine which input device your keyboard is. To figure that out, you look at /proc/bus/input/devices. (Thanks to Jakub for this solution)

I tested this on two a keyboards:

  1. PS1 keyboard connected via PS1 to USB adaptor with Holtek chipset (04d9:1400)
  2. A cheap numeric keypad, also with Holtek chipset (04d9:1603), HT82M99E.

Result: It works for the former but not the latter.

Perhaps someone knows whether that's a driver issue or a problem of the hardware itself (not responding to requests from the driver).





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.