switch-layout icon indicating copy to clipboard operation
switch-layout copied to clipboard

Strange behaviour when detect caps_lock

Open dmgl opened this issue 5 years ago • 1 comments

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

dmgl avatar May 20 '19 15:05 dmgl

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.

yamnikov-oleg avatar Dec 09 '19 17:12 yamnikov-oleg