Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make windows key parsing logic better #619

Merged
merged 2 commits into from
Feb 6, 2022
Merged

make windows key parsing logic better #619

merged 2 commits into from
Feb 6, 2022

Conversation

WindSoilder
Copy link
Contributor

@WindSoilder WindSoilder commented Nov 21, 2021

Handle #536 in windows

For more reference about the comment:

The other implementation is to take the ASCII code produced by the key and bitwise AND it with 31, forcing bits 6 and 7 to zero. For example, pressing "control" and the letter "g" or "G" (code 107 in octal or 71 in base 10, which is 01000111 in binary), produces the code 7 (Bell, 7 in base 10, or 00000111 in binary).

https://en.wikipedia.org/wiki/Control_character

And here:

Pressing Ctrl together with a letter or other symbol written 10xxxxx₂ (binary notation) sends the control character whose code is 00xxxxx₂, e.g. Ctrl+[ sends character number 27₁₀ = 0011011₂ because [ is 91₁₀ = 1011011₂.

https://vi.stackexchange.com/questions/3225/disable-esc-but-keep-c

@superlou
Copy link

Using the event-read.rs example, I verified on Windows 10 that nothing is printed for ctrl+[ with Crossterm 0.22. Applying this PR to master provides the expected result:

Event: Key(KeyEvent { code: Char('['), modifiers: CONTROL })

@archseer
Copy link
Contributor

Hey @TimonPost sorry for the bump but could we get a review on this?

@TimonPost
Copy link
Member

Thanks for the PR, seems to work quite well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants