google / extra-keyboards-for-chrome-os

Extra keyboard layouts and input methods for Chrome OS
Apache License 2.0
201 stars 123 forks source link

Colemak modifier remapping #102

Closed gkudelis closed 3 years ago

gkudelis commented 3 years ago

I'm trying to use a regular US colemak layout and also swap Ctrl and Alt modifiers using chrome os settings - this mostly works, but in the colemak layout the right Alt key is AltGr and the chrome os modifier switching does not work on it, leaving me without a Ctrl key on the right-hand side. Using a qwerty layout this is not an issue and I get both left and right Ctrl keys. I think if I create a layout that replaces the AltGr key with a regular Alt key this should solve my problem.

Is it possible to set up a US colemak keyboard layout without the AltGr modifier? If so - how should I go about this? I understand xkb to a degree and it seems like some of the options in the custom layouts mirror xkb notation, but I'm unable to connect the dots...

bderrly commented 3 years ago

I really should finish up the documentation I began a while back about how to connect those dots.

In looking at this more I'm not sure if there is a way to do what you want with ChromeOS as is. Specifically, I believe the Colemak layout that is provided by default is the same coming from xkeyboard-config. Looking at that configuration you see it adds include "level3(ralt_switch)" (see symbols/level3 for details) which is what converts the right Alt key into AltGr. If you had access to a config file or a command line (like you would on a linux system) you could execute something like setxkbmap -option ralt_alt which would "undo" the include from the Colemak layout thus leaving you with a default Alt key. However, since we do not have such options with ChromeOS I think we may be stuck with the AltGr.

The extensions here do not have the ability to modify the xkb configurations only reference them for use by the system. That is, in the manifest.json file we can request that the system use a specific layout, e.g. "layouts": ["gb(colemak)"] but we cannot then request that it not use the level3 include I referenced earlier.

It might be possible to do some sort of key intercepting similar to how the composekey extension works. I would need to play around with it to see if it would be possible to intercept the AltGr press and send a plain Alt to the system. If you're up for it you might want to try some local extension that copies some of the code from composekey narrowed down to just the Alt keys but is based on Colemak layout.

hickford commented 3 years ago

See also https://crbug.com/985237 "Modifier handling is duplicated between xkb and EventRewriterChromeOS" . This is the ultimate cause of issues such as https://crbug.com/914221 "Caps Lock is not correctly remapped when using the Colemak keyboard"