rust-embedded-community / pc-keyboard

PS/2 Keyboard Decoder in Rust
Apache License 2.0
96 stars 28 forks source link

Update AltGr handling to accept Ctrl+Alt, add Norwegian keyboard layout #34

Closed alexrsagen closed 1 year ago

alexrsagen commented 1 year ago

At least in the Norwegian keyboard layout, Ctrl+Alt is equal to AltGr.

Also, the right alt key is only AltGr on some keyboard layouts, not all layouts have an AltGr key. I haven't changed anything in this regard, but it might be useful to make that distinction in the different keyboard layouts in the future (instead of in EventDecoder::process_keyevent).

jonathanpallant commented 1 year ago

Thank you for the PR!

For the record, could you post a photograph here of a keyboard featuring this layout?

alexrsagen commented 1 year ago

The following images show keyboards with a scandinavian (Norwegian/Danish/Swedish/Finnish?) ISO layout.

HP 803181-DX1:

23BD386E-934E-4657-BE4F-4943E2D3DDBB

Logitech MK710 (Norwegian keys are colored green):

67388E6A-3F5F-44DE-9E4E-600E033781FC

jonathanpallant commented 1 year ago

The key to the left of the Backspace has about five symbols on it!? Can you briefly explain how this works?

jonathanpallant commented 1 year ago

To the left of the Number 1 key, we've got six symbols, one of which is repeated 3 times...

alexrsagen commented 1 year ago

Welcome to the cursed world of international keyboard layouts. Yeah, some of the symbols on those keys are for different keyboard layouts. I suggest looking at the Logitech keyboard, as it colors the Norwegian layout options in green.

For the Norwegian layout, the following applies:

All applications support the accent key, but I'm not sure if the OS is responsible for handling this or the individual application. Thus, I am not sure if pc-keyboard should also handle this.

jonathanpallant commented 1 year ago

Ah, I think they are called "dead keys". Currently the user of pc-keyboard will need to observe that a dead key has been pressed, and do the right thing with the next key that comes out. We could perhaps add something so that you know when it is a dead key and when it isn't, or perhaps even do the combination automatically if you request it.