houmain / keymapper

A cross-platform context-aware key remapper.
GNU General Public License v3.0
295 stars 25 forks source link

[DOC] How to deal with deadkeys/diactritics ? #96

Closed Kochise closed 8 months ago

Kochise commented 9 months ago

Hi,

I'd like to know how to :

  1. Press [AltGr]+<key 1> : register diacritic
  2. Press <key 2> : apply diacritic on <key 2> (if possible)

I already made a msklc configuration that works on Windows yet I wanted to port it to Linux :

https://github.com/wenuam/wm_key_layout_cfilorux/blob/main/map/Windows/msklc/cfilorux.klc

BTW the Windows keyboard is FR-AZERTY while the Linux keyboard is US-QWERTY.

Hope it doesn't changes too much the key name :

https://github.com/houmain/keymapper#key-names

From my understanding and first test, it might be possible to make the same configuration file for the two systems, based on the hardware scan code :

https://kbdlayout.info/kbdusx/scancodes https://en.wikipedia.org/wiki/Scancode https://deskthority.net/wiki/Scancode

Here's what I got so far, but keymapper fails on line 148 :

0x03 'a' >> 'å' <-- The "modifier" ought to be released before pressing 'a'

keymapper.conf.txt

Either the input expression is wrong, or the output expression is unable to emit an Unicode character.

I tested to output an Unicode hex values but still fails.

Regards.

houmain commented 9 months ago

Hi Kochise, It fails in line 148 because string literals can only be added to the output side. Unfortunately the typing of letters which require deadkeys like 'å' are not supported yet. One has to map it to the sequence of keys one has to press. e.g. Control{A} >> Backquote A (for â on a german keyboard).

houmain commented 9 months ago

I do not understand yet why you use the hex scan codes instead of the key names. Does it really make a difference?

Kochise commented 9 months ago

Hi, thank for your answer.

Yeah I tried on Windows with a FR-AZERTY keyboard the Q/A W/Z keys gets inverted, not with the scan code.

Hope to get deadkeys support soon :)

Kochise commented 9 months ago

I tried to create a keyd mapping, but many keys gets wrongly remapped, despite using keyd monitor first :

default.conf.txt

ristomatti commented 9 months ago

Not an answer to your question but a similar workaround. I'm chiming in as I just today struggled for a while with getting Finnish lettersäÄöÖ working in a practical way on a ANSI US Layout. I've been using a "Finnish (no dead keys)" layout (on Linux) specifically to NOT have to type an extra space after ^, ~ or `. Backtick is specifically annoying given the amount of Markdown I use every day...

After some experimenting I settled with the OS layout "English (intl., with AltGr dead keys)" combined with these mappings:

[device=/Keychron K15 Pro/]
  AdieresisKey = A | Quote                                                                                       
  OdieresisKey = O | Semicolon                                                                                   

  AltGr{AdieresisKey} >> AltGr{Q}                                                                   
  AltGr{OdieresisKey} >> AltGr{P}

This way I can either get the keys from their original physical location or from A and O. But yea, I can understand it'd be much more difficult to find a similar configuration for French letters.

(Å is also part of the layout but it's primarily used only by the Swedish speaking Finns.)

Kochise commented 9 months ago

Thank for your solution, but the layout I made is a completely redesigned from the ground up, that sure provides almost every accent out there, but using AltGr to get there. Of course I expect the auto-correct feature of modern editors to set the accents for me if it detects that's the only thing missing (all letters are there, just not the accent).

Does the keymapper.conf file at https://gitlab.com/-/snippets/2219583 provide some clues about how to get it done ?

Anyway I'm still struggling with this on Linux while it took me less than 2 hours to figure it out and have an installer working on Windows, using a 20+ yo software that is. I advice you to test it so that you can understand how it's supposed to behave (aka NOT have to type an extra space after ^, ~ or ```).

houmain commented 8 months ago

Hi, thank for your answer.

Yeah I tried on Windows with a FR-AZERTY keyboard the Q/A W/Z keys gets inverted, not with the scan code.

Hope to get deadkeys support soon :)

Some keys were indeed still mixed up. This should be fixed in 3.5.0. It also supports strings containing diactritics (only on Windows for now).