alex / alex/what-happens-when

Keystroke internals

Đang mở
#321 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
43.3k
Fork
5.7k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

First of all, just like to say - I love this.

In the spirit of _we're going to try to answer this question **in as much detail as possible**_ though I think there are are some missing pieces in the initial 'keystroke' parts, which I have wondered if I would use if I was ever asked this in an interview.

> The "g" key is pressed

- Has a modifier key been pressed as well?
- Is this part of a dead-key combination?
- Is this part of a diacritic?
- Has a [compose key](https://en.wikipedia.org/wiki/Compose_key) been pressed?

With Windows, I used to have a handle on how some of these worked internally, but that project was a long, long time ago, and all I am left with is the vestigial knowledge that such things exist. Nevertheless, all major OSs will have support for these.

The one I can still remember well enough - on Windows - is a check that would be made:

- Has the letter 'g' been mapped to another key?

This is the concept of 'scancode mappings' - where a keypress is interpreted as another key.

On Windows these are saved in the registry, apply to all users [0], and would be checked on each keystroke. Here's an example of a mapping from `f` to `h`:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,23,00,21,00,00,00,00,00

In this case, the check would be made and the answer would be _'no, `g` has not been mapped to another key'_

On Linux,[`xmodmap`](https://man.linuxreviews.org/man1/xmodmap.1.html) and [XKE](https://wiki.archlinux.org/title/X_keyboard_extension) look like they do the same, and on OSX there are [third-party programs](https://karabiner-elements.pqrs.org/docs/manual/configuration/configure-simple-modifications/) which perform the same function.

[0] Windows XP had per-user scancode mappings, but it was undocumented and removed in Vista..

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.