makerdiary / python-keyboard

A hand-wired USB & Bluetooth keyboard powered by Python and more
https://makerdiary.com/m60
MIT License
486 stars 61 forks source link

Added ability to adjust tap and pair key delays #7

Closed mehalter closed 4 years ago

mehalter commented 4 years ago

Added basic functionality for users to adjust keyboard delay. What is the 200 delay on line 261 represent? Is this another value that should be adjusted? I couldn't tell exactly what was happening there with my basic understanding of the codebase currently

xiongyihui commented 4 years ago

The 200 ms delay is used to distinguish between Tap-key and fast typing. If we type D (a Tap-key) andU fast, U is pressed before D is released, and D is released before Uis released.

     D down    U down   D up     U up
      |         |        ^        ^
      v         v        |        |
------+---------+--------+--------+---------> t

      <--------> <------>
         dt1       dt2

200 is a threshold of dt2. Maybe we should set the threshold based on dt1.

By the way, I was thinking to change is_tapped to is_tap_key. How do you think?

mehalter commented 4 years ago

Ok that makes sense. I made that an adjustable property as well. I thought abotu a good way to make it dependent on dt1, but I think people will like to be able to tweak each value individually.

Also I like the name change to is_tap_key I think it makes it more clear what it is checking. I made this change as well.

xiongyihui commented 4 years ago

Thanks. Merged.