Share via

japanese IME is breaking my python script keybinds

j c 11 Reputation points
2021-05-10T21:11:08.76+00:00

I wrote a program for a customer service agent who uses windows 10. A hotkey is bound using the keyboard module, and it works like a charm, UNTIL the user presses CapsLock to swap to Microsoft IME Japanese.

Once that swap is made, the hotkey that my program has bound does not function anymore, and the program must be restarted.

I checked the key output in each keyboard mode, and they both output the same char, ' \ '.

Could someone speculate as to what the problem could be, and perhaps even a potential resolution?

`import keyboard  keyboard.add_hotkey('\', callFunction)`
Community Center | Not monitored

1 answer

Sort by: Most helpful
  1. scsung 0 Reputation points
    2023-11-03T01:16:48.6866667+00:00
    In my case, the same problem occurs when I press the corresponding key on the 103/106 keyboard, which has separate Korean/English conversion keys.
    
    When monitoring keystrokes using python -m keyboard, keyup events do not occur for those keys.
    
    It seems that the IME keys affect shortcut key combinations.
    
    I'm looking into a way to initialize the IME key by triggering a keyup event, but it's not easy.
    
    An easier solution is to register both combinations ("\", "hangeul+\") as shortcut keys when registering shortcut keys.
    
    keyboard.add_hotkey('\', callFunction)
    keyboard.add_hotkey('hangeul+\', callFunction)
    

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.