-
Notifications
You must be signed in to change notification settings - Fork 286
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
Not able to stop control+M from being an Enter #633
Comments
What platform and terminal? |
I noticed this also. I'm using Ubuntu 21.10. It's not terminal dependent (same results in xterm, kitty, gnome-terminal, urxvt). Here are some results (I would like someone else to also test this):
I don't know much about terminals. My first reaction was, that it is related to ascii control codes (https://en.wikipedia.org/wiki/Control_character). This also happens in any terminal application I tested, like ranger or vim. Try pressing Ctrl+M (Return) or Ctrl+8 (Backspace) in vim. I was confused why Ctrl+m doesn't work, but Ctrl+j or Ctrl+c does. It might be related to: #371. crossterm/src/event/sys/unix/parse.rs Line 74 in 9bc5cd3
|
FWIW, I had originally fixed the Ctrl+J issue with #373. There's some information in the PR, as well as this link, which you may find particularly relevant, @wags-1314. The basic problem is this: The way that characters are encoded in terminal emulators means that Ctrl+J and '\n' are the same character -- it is not possible to distinguish them. AFAICT, the fix for #371 was just to reinterpret the byte sequence for '\n' as Ctrl+J, when we're in raw mode. For Ctrl+J, this makes sense -- raw mode actually means that anything that would be a newline (i.e. enter) gets reported as such, so anything with the byte sequence for Ctrl+J must actually be Ctrl+J. But for Ctrl+M, there isn't such a distinction. It is exactly the same as Enter -- that's why there aren't any terminal programs that are able to distinguish them. So I don't know what crossterm should do. IMO, this behavior is the best it can be - (people more often want to check for Enter, not Ctrl+M, I think). Also relevant: #569 - which IIRC would provide a way around this, for users of the kitty terminal. |
Related: #594 |
WezTerm also supports Fix Terminals - Please. |
Closing in favor of #685. |
I am using crossterm to make a text editor of sorts. I am switching into raw mode and simply echoing the keypresses. Here is my code:
When I enter
control+M
I getKey(KeyEvent { code: Enter, modifiers: NONE })
instead ofKey(KeyEvent { code: Char('m'), modifiers: CONTROL })
. How do I make this happen?The text was updated successfully, but these errors were encountered: