Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tapkeys Too Slow for Regular Touch Typing #11

Open
CVYY39 opened this issue Sep 17, 2020 · 19 comments
Open

Tapkeys Too Slow for Regular Touch Typing #11

CVYY39 opened this issue Sep 17, 2020 · 19 comments

Comments

@CVYY39
Copy link
Contributor

CVYY39 commented Sep 17, 2020

Out of the box, the first thing I noticed is that the d, b, and ; keys had issues. Typing "dead dead dead" at quick-ish speed (I'm no speed demon) comes out as "dea dea dea" 100% of the time. I tried each of the other keys, and noticed the same behavior with b and ;.

Reading the docs, I saw that these are intended to function as "tapkeys." That sounds great in theory, but as-is they are far too slow for regular typing.

I resolved this for myself by disabling the tap keys in the code.py configuration file. But it looks like the tapkeys feature needs some more testing with regular touch typists.

@xiongyihui
Copy link
Contributor

Thanks for reporting the issue. It is a bug. I will fix it soon.
When a key is pressed but not released before a tap-key is pressed, the program failed to handle it.

   a↓      d↓      a↑       d↑
 --+-------+-------+-------+------> t

d as a tap-key

@xiongyihui
Copy link
Contributor

@CVYY39 Could you test it again with the latest keybaord library? Just updated it.

  1. Copy keyboard folder of this repo to the lib directory of the CIRCUITPY USB drive.
  2. Replace from PYKB import * to from keyboard import * in code.py of the USB drive.

@CVYY39
Copy link
Contributor Author

CVYY39 commented Sep 17, 2020

I reverted my code.py to the one from the repo and followed the steps you listed. It looks like it is improved but not resolved completely. It previously happened 100% of the time, now it is more like 10-20%.

@xiongyihui
Copy link
Contributor

Are you able to distinguish the difference?
If you type very fast, you can also adjust the debounce time by adding the following line before keyboard.run() in code.py

keyboard.matrix.debounce_time = 5    # about 5 milliseconds

The default debounce time is about 15 milliseconds.

@CVYY39
Copy link
Contributor Author

CVYY39 commented Sep 17, 2020

It's not hard to see it still happening, unfortunately. Here are a strings of "vb" and "sd" typed repeatedly:

v v vb vb vb vb vb vb vb vb vb vb vb vb v vb vb vb vb vb v v vb vb vb vb vb vb vb vb vb vb v
sd s s s s s s sd sd s s s s sd sd s sd s s s s sd

You can see it's dropping the b and d quite a bit.

For comparison, here is "rt" typed exactly the same way with TapKeys enabled:

rt rt rt rt rt rt rt rt rt rt rt rt rt rt rt rt rt rt rt rt rt rt rt rt rt rt rt rt rt rt rt rt

It doesn't drop a single one.

Here is "sd" with the TapKeys disabled:

sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd sd

Not a single one missed.

In practice, it only seems to drop characters occasionally in normal typing with TapKeys enabled (i.e., when I'm not trying to trigger it) but that is really still too often. I mean, it's probably dropping them more often than my old Macbook Pro, and that was enough to cause Apple to recall the keyboard.

@xiongyihui
Copy link
Contributor

xiongyihui commented Sep 17, 2020

How do you type space?

Typing like the following sequence will likely lose d.

   d↓   space↓   space↑    d↑
 --+-------+-------+-------+------> t

You can use other keys as the tap-keys. Maybe replace d with capslock and replace b with menu

@CVYY39
Copy link
Contributor Author

CVYY39 commented Sep 17, 2020

Yeah, that is what I did. I've always used Capslock that way anyway on other keyboards anyway. I just wanted to flag the issue, because I'm sure others who get the board will notice the dropped keys over time.

I don't think I'm pressing space before I release b / d. But even if so, I've never noticed any similar problems on other keyboards.

@xiongyihui
Copy link
Contributor

If you use d as a tap-key on other keyboards, do they have the same issue?
I think the issue is a by-product of the tap-key. We can also change the define of the tap-key.

For example, replace is_tapping_key(key) with:

    def is_tapping_key(self, key):
        matrix = self.matrix
        n = len(matrix)
        if n == 0:
            n = matrix.wait(
                self.tap_delay - matrix.ms(matrix.time() - matrix.get_keydown_time(key))
            )
        if n >= 1:
            return True

        return False

def is_tapping_key(self, key):
"""Check if the key is tapped (press & release quickly)"""
matrix = self.matrix
n = len(matrix)
if n == 0:
n = matrix.wait(
self.tap_delay - matrix.ms(matrix.time() - matrix.get_keydown_time(key))
)
target = key | 0x80
if n >= 1:
new_key = matrix.view(0)
if new_key == target:
return True
if new_key >= 0x80:
# Fast Typing - B is a tap-key
# A↓ B↓ A↑ B↑
# --+-------+-------+-------+------> t
# | dt1 |
# dt1 < tap_delay
return True
if n == 1:
n = matrix.wait(
self.fast_type_thresh
- matrix.ms(matrix.time() - matrix.get_keydown_time(new_key))
)
if n >= 2 and target == matrix.view(1):
# Fast Typing - B is a tap-key
# B↓ C↓ B↑ C↑
# --+-------+-------+-------+------> t
# | dt1 | dt2 |
# dt1 < tap_delay && dt2 < fast_type_thresh
return True
return False

@mehalter
Copy link
Contributor

Hm with these latest commits I am getting bad experience when doing keybindings with the tap key and it thinking that I am typing 2 keys. Is there a nob for this new feature that I could tweak to get back to the original behavior or dial in the parameters to match my typing style?

@mehalter
Copy link
Contributor

Also I was experiencing the same issue that you are describing @CVYY39 which is why i added the ability to adjust the tap delay and the fast typing threshold using the self.tap_delay and self.fast_type_thresh properties in the Keyboard class. For example, I have mine set to

keyboard.tap_delay = 200
keyboard.fast_type_thresh = 100

in my code.py. Also this was added recently, so you need to be using the github repo keyboard folder in the lib/ folder of the M60 keyboard as was described above.

@xiongyihui
Copy link
Contributor

I just created a branch named debug to print some logs of tap-keys. Would you mind to test the branch and share the log of misfunction tap-keys here? It will help us to make tap-keys usable for most cases.

@xiongyihui
Copy link
Contributor

@mehalter Have you tried to reduce the debounce_time?

The default debounce time is about 15 milliseconds, It may be too long. We can change it to:

keyboard.matrix.debounce_time = 5    # about 5 milliseconds

@CVYY39
Copy link
Contributor Author

CVYY39 commented Sep 23, 2020

With the debug branch, the problem only seems to occur with small words like "ad, "ab," or "cab," at least so far. I mainly only see the issue when I'm trying to trigger it. How do I pull the logs that you mentioned?

@mehalter
Copy link
Contributor

mehalter commented Sep 23, 2020

@CVYY39 You can see the logs by reading the serial output of the keyboard while having it connected via USB. I found it by looking through /dev on my linux machine. Mainly looked at the difference of that folder with and without having the keyboard plugged in and found that it was /dev/ttyACM0 on my machine. This is not necessarily true for whatever machine you are on. Once you identify the serial connection to the keyboard you can set keyboard.verbose = True in code.py and then run cat /dev/ttyACM0 on the command line and see all of the logs.

@mehalter
Copy link
Contributor

@xiongyihui reducing the debounce_time to 5 helped with my issues and I don't experience the issue of tap keys after tuning the debounce_time, tap_delay and fast_type_thresh to fit my typing speed/style.

@xiongyihui
Copy link
Contributor

@mehalter Wow! Your typing speed is fast. Maybe we should set the default debounce_time to 5 or 10.

@CGMossa
Copy link

CGMossa commented Oct 9, 2020

I have also experienced tap-keys being a bit problematic when I type really, really fast.
If you could give an update on this issue, that would be great.

@xiongyihui
Copy link
Contributor

@CGMossa Does changing debounce_time to 5 milliseconds or 10 milliseconds solve the issue?

In code.py, add a line before keyboard.run()

keyboard.matrix.debounce_time = 5    # about 5 milliseconds

@CGMossa
Copy link

CGMossa commented Dec 1, 2020

I'm still having issues..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants