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

Combination of CONTROL + <Non-Alphanumeric> i.e. [ , ], \, / etc. gives, faulty readings or no readings at all. #536

Closed
ahmednooor opened this issue Jan 5, 2021 · 6 comments

Comments

@ahmednooor
Copy link

Describe the bug
Combination of CONTROL + <Non-Alphanumeric> i.e. [ , ], , / etc. gives, faulty readings or no readings at all.
// OUTPUT
// Press Ctrl+[ : KeyEvent { code: Esc, modifiers: NONE }
// Press Ctrl+] : KeyEvent { code: Char('5'), modifiers: CONTROL }
// Press Ctrl+/ : KeyEvent { code: Char('7'), modifiers: SHIFT | CONTROL }
// Press Ctrl+\ : KeyEvent { code: Char('4'), modifiers: CONTROL }
Some events such as Ctrl+, and Ctrl+. are not read at all. Ctrl+[ is not read in cmd.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'https://github.com/ahmednooor/crossterm-err-rep-05012021/blob/main/src/main.rs#L25-L29'

Clone repo and cargo run.

Expected behavior
// Press Ctrl+[ : KeyEvent { code: Char('['), modifiers: CONTROL }
// Press Ctrl+] : KeyEvent { code: Char(']'), modifiers: CONTROL }
// Press Ctrl+{ : KeyEvent { code: Char('{'), modifiers: SHIFT | CONTROL }
// Press Ctrl+} : KeyEvent { code: Char('}'), modifiers: SHIFT | CONTROL }
// Press Ctrl+/ : KeyEvent { code: Char('/'), modifiers: CONTROL }
// Press Ctrl+\ : KeyEvent { code: Char(''), modifiers: CONTROL }
// Press Ctrl+, : KeyEvent { code: Char(','), modifiers: CONTROL }
// Press Ctrl+. : KeyEvent { code: Char('.'), modifiers: CONTROL }

OS

  • e.g. Windows

Terminal/Console

  • e.g. Windows Terminal

P.S. Thank you for creating this. It has worked beautifully so far.

@ahmednooor
Copy link
Author

Could be related to #504

@ahmednooor
Copy link
Author

Some Initial Findings

After some println! here and there, it seems that,

in crossterm_winapi>src>console.rs>read_input()>ReadConsoleInputW(),

the underlying winapi returns the same record for Escape key and Ctrl+[ keys,

[INPUT_RECORD { EventType: 1, Event: INPUT_RECORD_Event([1, 1769473, 1769473, 0]) }].

So there might not be any way for crossterm to differentiate between the two.

@Arcterus
Copy link

Arcterus commented Mar 8, 2021

I'm having this issue on Linux. Ctrl+] and Shift+] don't seem to work, but Alt+] does. Note that ] is just an example, as I'm having problems with other keys as well (e.g. [ doesn't even work with Alt).

Also, Alt+] doesn't seem to work at all in XTerm, but works fine in GNOME Terminal.

@Lucky4Luuk
Copy link

Having a similar issue on Pop!_OS with the default terminal. Ctrl+[ and Ctrl+] don't work at all, and Alt+[ and Alt+] barely function.

@TimonPost
Copy link
Member

TimonPost commented Jun 30, 2022

Windows implementation was fixed by #651

@TimonPost
Copy link
Member

Also closing in favor of #685 for the linux reported keys in this issue.

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

No branches or pull requests

4 participants