caksoylar / keymap-drawer

Visualize keymaps that use advanced features like hold-taps and combos, with automatic parsing
https://caksoylar.github.io/keymap-drawer
MIT License
746 stars 62 forks source link

Feature request: Alt-Gr key labels #32

Closed chrissicool closed 1 week ago

chrissicool commented 1 year ago

Hi,

keymap-drawer has the the following fields that show up for a key: tap, hold and shifted. Some European keymaps make extensive use of the Alt-Gr (aka. right ALT) key to add another layer of keys. These mostly include signs like @, , [, ] or |. See the AZERTZY layout, for example.

It might be beneficial to have some of them printed on the generated keymap. Using the hold field as an alternative is not a good option, since Alt-Gr is (like the shifted state) a tap field., which is additional to all the other fields which are already present. I propose to add another field to LayoutKey, maybe called alt. It could be printed on the right side of the physical key.

caksoylar commented 1 year ago

Hey, I had intended the shifted field to cover all such modifier scenarios -- for instance ZMK parsing assigns any mod-morphed binding to that field regardless of the modifier. However, from your AZERTY link I can see how you might want separate Shift/AltGr alternate functions, on e.g. the number row keys.

Currently, some workarounds can be:

I propose to add another field to LayoutKey, maybe called alt. It could be printed on the right side of the physical key.

This could be a solution although I am a bit hesitant to add more fields; especially with left/right fields it might be difficult to preserve clarity and not look too busy. It would essentially be constrained to 1-2 char values but that should be fine for your use case. I'll think about it and maybe give it a try to see how that looks, both outcome and implementationwise.

magicDGS commented 2 weeks ago

I am also really interested in this feature, as otherwise there is a very difficult way to implement non-US OS based keyboards that can be represented with keymap-drawer: for example, in my keyboard I have some Spanish symbols that I prefer to keep on the default key-bindings and not use a dedicated layer/combo to create them because they are not widely used. This is nice to visualize when you are learning a new layout, as sometimes muscle memory in normal keyboards is really strong that you don't really realize where they are, and then on a different layout it will cost a bit more (even more if the physical keycaps are completely blank).

Last but not least, I believe that having a new field is benefitial to help even with the css customization, as I am also finding quite difficult to style certain specific keys (although this is a different issue, but I believe that in the case of Alt and/or AltGr this will be easier to fix on this specific case).

At the moment, a language like Spanish with limited custom css and configuration looks like this for a qwerty-based layout with shifted+alt keys (separated by space), which looks quite busy (numbers and special chars are the most difficult to read):

imagen

And in the case of using key-sides it looks even worse:

imagen

Some proposals from my side are the following:

@caksoylar - I can try to support with one of the options and contribute if you feel that this is a posibility.

caksoylar commented 2 weeks ago

I think I like the third option as a generic solution to this. Clearly there is demand to add more than three legend fields to the key for some cases, and the user can be responsible for ensuring clarity. I probably wouldn't add any support for parsing to emit the new fields or emphasize it in the docs as the main method, but the following could be fine:

If you want to work on above, I'd be happy to receive a PR.

magicDGS commented 2 weeks ago

I will need to get a bit more familiar with the codebase to contribute, but to do so I would like also some clarification of what right/left will mean then: only right and left from the center (tap) by default?

I will let you lnow when you tell me that part when I get started with the contribution, as I don't wanna block the feature if you or somebody else wanna work on it.

caksoylar commented 2 weeks ago

I will need to get a bit more familiar with the codebase to contribute, but to do so I would like also some clarification of what right/left will mean then: only right and left from the center (tap) by default?

Yes, I am imagining it to mean center-left and center-right. The right one would have e.g. text-align: right in its CSS, and they would be placed right inside the left and right edges of the box, centered vertically like tap and offset horizontally by inner_pad_w.

I will let you lnow when you tell me that part when I get started with the contribution, as I don't wanna block the feature if you or somebody else wanna work on it.

Sure, let me know. I don't think it would be particularly complicated unless something unexpected comes up. If you can't get to it soon let me know too, I can have a look.

magicDGS commented 2 weeks ago

I have started the implementation and a PR will come soon, as I found some problems with the alignment of the right label (probably due to skill issues, to be honest).

caksoylar commented 1 week ago

I'll close this since we now have left/right legend types in https://github.com/caksoylar/keymap-drawer/commit/b701cef57b4837d23fdec1a21d081c53a5c3daf3, so e.g. right field can be used for AltGr labels by convention.