-
Notifications
You must be signed in to change notification settings - Fork 135
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
ralt is sending lctl press #55
Comments
Thanks for filing the bug! I'll have to look into the specifics of the altgr key. |
So according to this link on Windows, altgr is somehow mapped to ctl+alt which makes sense for what you're observing for the press. What I'm not sure about is why both don't get released when you release altgr. It's not clear to me if kanata is doing something wrong or the Windows event hook is. I'll try looking at other projects to see if they've encountered and solved this issue. |
Thanks for looking into this! Was using kmonad previously on my Linux machine, but Windows issues led me to kanata. Just testet the same config with kmonad, and it seems like it also suffers from the same issue. I then found kmonad/kmonad#530. |
It's also worth mentioning that I use Alt Gr frequently when programming, and have not seen the same error in Ubuntu and NixOS (using kmonad). So my guess is that this is a Windows-only issue. |
The problem is that Alt Gr is not defined in the kanata keycode. Although you put ralt in defrc, you are not pressing ralt. I believe Alt gr should be added as a key. |
So it partly seems like this is a Windows problem. Even a project with waaaay more resources than kanata or kmonad is punting on this problem in some ways: https://github.com/microsoft/PowerToys/issues?q=is%3Aissue+is%3Aopen+altgr But it's worth thinking about ways to mitigate this. @13minutes-yt from my understanding the USB scancode for ralt and altgr are actually the same. It's the OS keyboard configuration or maybe the locale that changes the behaviour. I could be wrong, but this is what I think based on what I've been reading up on. |
You r right ,same scancode. I found this link by tweaking registry. https://www.getdroidtips.com/remap-alt-gr-key-windows-10 |
Sidenote, I can remove every key in my config except lctl and the problem still perist. Which makes sense if AltGr is mapped to alt+ctl. Heres the minimal config:
This results in the following when pressing AltGr:
|
@storvik would you be able to build and test #65 to see if either of the new optional configurations are useful in fixing this issue? My guess would be that something like the configuration below would be the most useful. This keeps the functionality of
I think that I'm just guessing here though; I don't use a layout that makes use of |
@jtroo built and tested and it seems to work. Both new optional configurations avoids the hanging ctl for me. I think it's nice to keep both options, but I am using Thank you so much for fixing this, will "test-drive" this version for a few days to make sure everything is working smoothly. |
@jtroo for some reason I am experiencing another issue with Windows, Alt Gr, GWSL and kanata. While everything related to Alt Gr seems to work fine in Windows now, I cannot get keys requiring Alt Gr to work in GWSL applications. For instance when I run Emacs from WSL I cannot input |
What's the kanata configuration of |
Seems like this issue is present in the main branch too, so it's probably not related to these changes. Both configurations causes the same behavior. It also seems like this issue is present in kmonad too. If I remove both lctl and ralt from my config it works correctly, but if one of them is present programs running on xserver does not interpret Alt Gr as it should. |
I wonder if GWSL is also using the low level keyboard hook that kanata is and kanata is somehow interfering with how GWSL operates. I'll poke around that codebase and maybe file a ticket to see if they know anything. |
That's possible. I think GWSL uses, or relies on, vcxsrv which seems to be a popular xserver for Windows. It's mentioned in the kmonad issue I sent above too. Please let me know if I can help with anything. |
Reading through some source code in my lunch break, I've understood the following points:
Reading the Microsoft documentation, it seems kanata is returning an incorrect value
|
Interesting. I tried to edit the config file for GWSL. Adding the Verified that new settings were picked up by VcXsrv by adding |
What GWSL configuration do you use? I've tried installing it to test myself but I'm not sure what to add to the configuration change the X apps to use an international layout. |
Playing around with kanata some more and adding logging, I've found that there are some peculiarities with the values in the keyboard hook that differ between injected and non-injected events. The boolean at the end of the log messages states if the event is injected or not. Logs when not intercepting:
Logs when intercepting lalt/lctl:
It appears that Windows has a concept of SYSKEY_UP/DOWN when pressing specific buttons like Alt/RAlt. This might be the source of the weirdness with GWSL. It also reveals a bit about why the LCtrl release gets missed However, I'm not sure how to fix the discrepancy. Looking at SendInput, there doesn't seem to be a way to simulate the |
Ah, so it seems that Interestingly I found that sending only E.g. with:
Side note: in Windows you can actually use LAlt+LCtrl to achieve the same thing as AltGr as it turns out. Unfortunately, I think fixing this issue for GWSL/vcxsrv will be quite the challenge so I'm not up to the task. This was an interesting investigation for sure though. You could try this as a workaround for GWSL apps if you find that other apps are also fine with the weird
|
I see, this goes deeper than I initially thought. Could not make it work with for other applications using the config above. The only solution I have is to disable handling of lctl and ralt in Kanata, as it is working properly without Kanata enabled. This is however not a major problem for me, as my setup does not need Kanata to handle / remap lctl and ralt. Thank you so much for investigating this! Kanata is working great for me. You can close this issue and merge the pull request, the initial problem with hanging lctl is solved and working. |
Hello and thank you for working on this.
I have an issue using kanata with windows. If my config (defsrc and deflayer) includes lctl it will send a lctl keypress when I press ralt. Here is the debug log:
What I am doing here is:
Here is my config:
To get around this issue I can simply remove
lctl
from my config and everything will work as intended.Not sure if it matters, but I am using norwegian keyboard layout with Alt Gr as right alt key.
The text was updated successfully, but these errors were encountered: