switch-layout
switch-layout copied to clipboard
Strange behaviour when detect caps_lock
I have settings in "Keyboard" section. My "Layout" "Settings":
Switch layout - Disable
Compose key - Disable
⌘ key behavior - Shortcut Overlay
Caps Lock bevahior - Disable
And your script don't work for me, because i have another key code for Caps Lock. But when i try to detect which key code i needed via xev
and xinput
linux command - they returned 66
key code.
I modified string in SWITCH_SHORTCUTS
to
{keyboard.KeyCode(66)},
but nothing happen.
So... I suggest to added some lines (or your variant):
def on_press(self, key):
if key not in self.monitored_keys:
print("Need to detect - ", self.monitored_keys) # this section
print("Detected key - ", key) # this section
return
self.current_keys.add(key)
self.keys_pressed += 1
print(self.keys_pressed)
if self.is_switch_shortcut():
self.on_switch()
it's helps to know which keycode need to use.
And my Caps Lock button have key code 16777215
Hi!
Thanks for the suggestion, I have added a debug flag to print pressed keys (it took me some time! :wink:).
I'll leave your issue open in case somebody has the same trouble with Caps Lock as you did.