Autoshift without the lag

Hey all,

I have loved using my UHK (v1) and am starting to dip my toes in the more advanced features. I’m looking for some advice on somehow implementing a no-lag version of autoshift. Apologies in advance for any wrong terminology, I haven’t programmed with hardware before.

When I enable autoshift (set autoShiftDelay 150), I experience a delay between pressing a key and seeing it on screen. I’m assuming this is because UHK captures a keypress, waits the autoshift duration, and only then sends a key (capital if still depressed, lower case otherwise). I can see the logic behind this, but it leads to a frustrating typing experience – kind of like typing into a laggy terminal. This effect only diminishes when the delay is low enough such that everything registers in upper case… I guess my eyes are quicker than my fingers.

The way I can think of to eliminate this lag would be: (1) capture keypress and pass through lower case key immediately; (2) wait for the first of key-up or autoshift duration expiry; (3) if autoshift duration expiry, send backspace + upper case letter. I’m a bit lost on how to implement such a thing with macros, if that’s even possible.

This is a bit complex for macros. At least to do it with macros in an elegant way.

Also, you have got a small problem: when the key-up happens, multiple characters may have already been pressed. (Indeed just a small problem that can be solved, although it makes the logic significantly more complicated, since you neeed to count and distinguish alphanumeric scancodes.)

So the recommendation is to dive into the c code. Autoshift is implemented in postponer.c, but in order to mess with complex character sequences, you will need more meddling.

As to macros, some proof of work may be:

postponeKeys holdKey a
postponeKeys ifPlaytime 400 {
    tapKey backspace
    tapKey A

This will still produce a lag, but the lag will apply for the next key down compared to current key up.

Also, it needs a separate macro for every key (:expressionless:).

Edit: Also, as to implementing things on current main, we are in the middle of a huge refactor, so I would advise to wait for 12.0.0 release with any medlding with the firmware…

Thanks for the quick reply! I’ll watch and wait for the 12.0.0 release and then get meddling.

Allright! Be warned that this will take some time (fall is optimistic estimate, spring pessimistic). Also, if you get it working, we would be glad for a PR :-).