jtroo / kanata

Improve keyboard comfort and usability with advanced customization
GNU Lesser General Public License v3.0
3.21k stars 131 forks source link

Directional Keys Not Working in Windows Task View #1042

Closed vinctsky closed 6 months ago

vinctsky commented 6 months ago

Requirements

Describe the bug

Hi,

I'm experiencing an issue with the Kanata after mapping my keyboard. The directional keys (up, down, left, right) do not work in the Windows Task View (shortcut: Win + Tab). However, the mapped directional keys function correctly in other applications and editors.

Please let me know if additional information is required or if there is a workaround for this issue.

Thank you for your help!

Relevant kanata config

kanata.kbd:

(defsrc
   grv  1    2    3    4    5    6    7    8    9    0    -    =    bspc
   tab  q    w    e    r    t    y    u    i    o    p    [    ]    \
   caps a    s    d    f    g    h    j    k    l    ;    '    ret
   lsft z    x    c    v    b    n    m    ,    .    /    rsft
   lctl lmet lalt           spc            ralt rmet rctl
)

(deflayer default
   grv  1    2    3    4    5    6    7    8    9    0    -    =    bspc
   tab  q    w    e    r    t    y    u    up    o    p    [    ]    \
   caps  a    s    d    f    g    h    left  down  rght    ;    '    ret
   lsft  z    x    c    v    b    n    m    ,    .    /    rsft
   lctl lmet lalt         spc             ralt rmet rctl
)

To Reproduce

  1. Configure Kanata with the above configuration file.
  2. Press Win + Tab to open Windows Task View.
  3. Attempt to use the mapped directional keys to navigate in Task View.

Expected behavior

The directional keys should allow navigation within the Windows Task View.

Kanata version

kanata 1.6.1

Debug logs

No response

Operating system

Windows 10

Additional context

Already tried opening kanata via admin mode.

jtroo commented 6 months ago

The only other things that I think might be worth trying is:

Otherwise this will probably be noted as another "Windows LLHOOK" known issue that has no workaround

eugenesvk commented 6 months ago

As far as I understand, the reason is that cursor keys (and a few other like home/end, see below) needs to be sent slightly differently - via Scan Codes instead of Virtual Keys. At least that's how AutoHotkey does it

For example, in the same ⌘⭾ task switcher:

+vkBB::{Send("{vk26}")} ; ✗FAILS
vkBB::{Send("{sc148}")} ; ✓WORKS

This might be the list of such special keys:

Currently g_key_to_sc contains NumpadEnter, Del, Ins, Up, Down, Left, Right, Home, End, PgUp and PgDn.

from https://www.autohotkey.com/boards/viewtopic.php?f=76&t=18836&p=91282&hilit=keyboard+hook+home+end#p91282

(tested with UIA on, it doesn't help here, cursor works in the elevated task manger, but not in this non-elevated task view)

eugenesvk commented 6 months ago

@lnnks can you test with the https://github.com/jtroo/kanata/releases/download/v1.6.1/kanata_scancode_experimental.exe version?

It sends scan codes for some special keys and works for me in the task view with your config

jtroo Maybe this version could be made the default in the next pre-release to force :) more testing to see if it has any issues since otherwise it's a better approach that's also used in AHK?

jtroo commented 6 months ago

Thanks for testing with winIOv2 eugenesvk!

Maybe this version could be made the default in the next pre-release to force :) more testing to see if it has any issues since otherwise it's a better approach that's also used in AHK?

I don't think I would do it for any v1.X.Y version. Doing so is a guaranteed breaking change for anyone using a non-US layout defsrc. Hopefully scancode output without scancode input should fix the problem as well though? And that shouldn't be breaking to use as default.

eugenesvk commented 6 months ago

yeah, scancode output is all that's needed

vinctsky commented 6 months ago

@eugenesvk thank you for your recommendation. after testing the version from https://github.com/jtroo/kanata/releases/download/v1.6.1/kanata_scancode_experimental.exe, I can confirm that this configuration works on my machine in the task view.

Additionally, as I mentioned, I have also tried the "enable in elevated windows" solution recommended by @jtroo, but unfortunately, it doesn't seem to work on my machine.