microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
110.87k stars 6.53k forks source link

Key got stuck when alternate(latch) key is mapped for physical key #18102

Open Arco-san opened 2 years ago

Arco-san commented 2 years ago

Microsoft PowerToys version

0.57.2

Running as admin

Area(s) with issue?

Keyboard Manager

Steps to reproduce

Prerequisite; using Japanese keyboard.

  1. Open powertoys and keyboard manager
  2. Mapping VK242/245, so-called Katakana/Hiragara/Romaji (it changes depends on IME setting) key to physical key
  3. Map destination key

✔️ Expected Behavior

The physical VK242/245 keys and newly mapped key output should work momentary switch just like other modifier key.

❌ Actual Behavior

The keys got stuck, keep pressed down and unable to un-press unless lock and unlock the screen. For example, if I using Explorer, when I press VK242/245 it got stuck and every mouse click on files open property window.

Other Software

No response

BlastBeated commented 2 years ago

The cause of this problem is probably the same as the following link https://github.com/microsoft/PowerToys/issues/3397

What environment is causing the problem? In the following cases, the powertoys team has tried to support Japanese IMEs in the past, but could not complete.

i. You are using a Japanese IME. ii. you are using the keyboard driver in the following link http://kbdlayout.info/kbd106n/virtualkeys?arrangement=OADG109A iii. you are using a JIS keyboard. https://en.wikipedia.org/wiki/Language_input_keys#/media/File:KB_Japanese.svg

I faced the same problem and checked how Windows understands the above environment. Software used: https://kts.sakaiweb.com/keymill.html

In kbd106, the following keys are toggle keys, but when any key is pressed, some of the other keys are key evented. Simply put, a single keystroke causes key events for multiple keys. i. "alphanumeric" key (same position as capslock but another key called vk_attn, capsclock is shift+alphanumeric). ii. "Hiragana/katakana" key iii. "Halfwidth/Fullwidth" key

For more information, please see here. https://github.com/kiripon/kbddv106/blob/master/kbd106.c#L523

However, I don't know which program is executing multiple key events in one key event.

BlastBeated commented 2 years ago

almost the same issue https://github.com/microsoft/PowerToys/issues/13955

Arco-san commented 2 years ago

I couldn't find how to check keyboard driver, but I think this situation meet all the three conditions. I searched about scan code and virtual key code, and found this article which explains a lot. AutoHotKey で正常に扱えないキーとその対策 - Qiita

I myself examined keyboard behavior using AutoHotkey software, and the result is same. When I press Katakana/Hiragara/Romaji key (which sends sc070), firstly it sends UP, and immediately pressing DOWN and holding it. I think this is the reason why swapped key got stuck. It actually sticking.

The test also shows that regardless of vk value change, sc value is consistent so there could be the way to resolve this issue. Hope this helps.