pynput icon indicating copy to clipboard operation
pynput copied to clipboard

Using vk keys hangs for a few seconds

Open mbyx opened this issue 3 years ago • 1 comments

Description A key that was created with KeyCode.from_vk, is much slower to press than one created with KeyCode.from_char This also occurs with every member of the enum Key.

Platform and pynput version Ubuntu 20.04 LTS (Using Xorg) pynput==1.7.3

To Reproduce

import pynput

c = pynput.keyboard.Controller()
c.tap(pynput.keyboard.KeyCode.from_char('a')) # This tap happens almost instantly.
c.tap(pynput.keyboard.KeyCode.from_vk(0x41)) # While this is much more slower

mbyx avatar May 20 '21 09:05 mbyx

Thank you for your report, and I apologise for the late reply.

The difference between keys having vk set and keys without is that when a virtual key code is provided pynput will use the XFAKE extension. This was implemented to allow using the internal state of the X server and allowing composing keys, and at the time it was assumed that keys with the vk attribute would generally only be those in th pynput.keyboard.Key enum.

How much of a latency increase do you experience?

moses-palmer avatar Oct 11 '21 19:10 moses-palmer