DreymaR / BigBagKbdTrixPKL

"DreymaR's Big Bag of Keyboard Tricks" for Windows with EPKL
Other
326 stars 32 forks source link

One-Shot Shift handles modified numbers incorrectly #35

Open samuelxyz opened 2 years ago

samuelxyz commented 2 years ago

To reproduce: Activate a Dvorak-Sym layout (which moves the numbers and puts them on the shift layer) and attempt to type numbers using one-shot shift. The expected behavior is that it should produce numbers, but the actual behavior is that it produces the QWERTY symbols corresponding to each expected number. For example, Shift QW_3 should produce 5, but instead produces %.

Typing numbers while keeping Shift held produces the numbers correctly.

DreymaR commented 2 years ago

Yeah, what's with that... Hmmm...

I can confirm your observation. There is a bug I didn't notice before that makes the Sticky Shift send the shifted version of the character mapped to the second state. This didn't matter until we encountered this layout variant which has unshifted numbers in the shifted states on the number row.

I'll look into fixing it when I have time.

jasper-day commented 2 years ago

Instead of the key codes for the shift layers, use unicode instead. Thus change 5 to ~35 and so on. One-shot shift is "overeager" with the keycodes but won't change unicode.

DreymaR commented 2 years ago

Technically, the sticky Shift isn't overeager: It does what it's designed to do, which is to hold down the Shift state for you until you either press a key or its timer runs out. However, the standard AHK Send function is a bit interesting in that it sends a "key" not a character by default. So this "key" gets shifted by the sticky Shift and trouble ensues when the character you wanted to send was an unshifted one in a shifted state entry. For already shifted characters in shifted state entries, you won't notice the difference.

Very clever idea of using Unicode! But also quite arcane in practice. I tried out a more intuitive solution which also turns out to work fine: The Send prefixes: Any one of % → $ § will work to send the literal character instead of the "key". Make sure you're using an updated version of EPKL for this!

In the next commit I'll fix the Dvorak Sym layouts, editing their shifted entries like this example which I found to work: QW_7 = 7 1 [ →7 -- @2c7 ¬ ; US 7& - dk_Caron Note the prefix before the 7 shift state entry there.

I realize that this program behavior is unintuitive, and I'll look into fixing it programmatically in the near future so special entries aren't necessary. The main problem is that if I send states as text by default, the key press won't work with the Win key! You should realize that your solved problem in this case comes at that price: Normal Win+number shortcuts (open programs in menu bar) won't work for you with these mappings.