keyboard icon indicating copy to clipboard operation
keyboard copied to clipboard

WSL Support

Open hysrx opened this issue 3 years ago • 2 comments

When I try to do a simple keyboard.wait('esc') I get the following:

hysrx@desktop:/mnt/c/src$ sudo /mnt/c/src/pypylinux/bin/pypy3
Python 3.7.4 (87875bf2dfd8, Sep 24 2020, 07:26:36)
[PyPy 7.3.2-alpha0 with GCC 7.3.1 20180303 (Red Hat 7.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>> import keyboard
>>>> keyboard.wait('esc')
/mnt/c/src/pypylinux/site-packages/keyboard/_nixkeyboard.py:110: UserWarning: Failed to create a device file using `uinput` module. Sending of events may be limited or unavailable depending on plugged-in devices.
  device = aggregate_devices('kbd')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/mnt/c/src/pypylinux/site-packages/keyboard/__init__.py", line 881, in wait
    remove = add_hotkey(hotkey, lambda: lock.set(), suppress=suppress, trigger_on_release=trigger_on_release)
  File "/mnt/c/src/pypylinux/site-packages/keyboard/__init__.py", line 639, in add_hotkey
    _listener.start_if_necessary()
  File "/mnt/c/src/pypylinux/site-packages/keyboard/_generic.py", line 35, in start_if_necessary
    self.init()
  File "/mnt/c/src/pypylinux/site-packages/keyboard/__init__.py", line 196, in init
    _os_keyboard.init()
  File "/mnt/c/src/pypylinux/site-packages/keyboard/_nixkeyboard.py", line 113, in init
    build_device()
  File "/mnt/c/src/pypylinux/site-packages/keyboard/_nixkeyboard.py", line 110, in build_device
    device = aggregate_devices('kbd')
  File "/mnt/c/src/pypylinux/site-packages/keyboard/_nixcommon.py", line 168, in aggregate_devices
    assert fake_device
AssertionError

I assume this is an incompatibility on WSLs end.

hysrx avatar Oct 02 '20 13:10 hysrx

@hysrx Consider trying sshkeyboard? I wrote it specifically to get around this issue. It is able to listen and react to keyboard input even on WSL2 / WSL, and through SSH.

ollipal avatar Oct 26 '21 13:10 ollipal

Thanks @ollipal that is a helpful comment

kurt-rhee avatar Nov 19 '21 18:11 kurt-rhee