crossterm-rs / crossterm

Cross platform terminal library rust
MIT License
3.18k stars 274 forks source link

[macos] `ctrl-i` is interpreted as tab #911

Closed FrancescElies closed 1 month ago

FrancescElies commented 1 month ago

Describe the bug ctrl-i seems to be interpreted as tab

To Reproduce Steps to reproduce the behavior:

  1. run cargo run --example event-read
  2. Click on i, then ctrl-i, then esc to quit
  3. See output ctrl-i is interpreted as tab

https://github.com/user-attachments/assets/888d3178-2347-475d-97a2-2348542db207

OS

Terminal/Console

joshka commented 1 month ago

You might find it a fun rabbit hole to go down as to why this is. But it's by design and likely not crossterm handling this, but your terminal. There are various control combinations that are equivalent, e.g. ctrl+[ Esc, ctrl+m Enter,and ctrl+i Tab. There are ways of disambiguating these, but they require terminal support and the app to turn on the ability.

See https://sw.kovidgoyal.net/kitty/keyboard-protocol/#legacy-text-keys for some in depth info. And the set keyboard enhancement flags command for turning this on (not supported everywhere, be careful).

I say "likely" above as there's a small chance this is emulated behavior in crossterm (I doubt it, but haven't checked explicitly IIRC, there are some emulated control codes).

FrancescElies commented 1 month ago

I see 😅, I was not aware of that, I guess I will keep have to keep that in in mind when binding shortcuts and keep myself away from ctrl-i, ctrl-m,

closing.

joshka commented 1 month ago

Confirmed that crossterm isn't doing anything special here - just mapping \t => KeyCode::Tab. https://github.com/search?q=repo%3Acrossterm-rs%2Fcrossterm+%22keycode%3A%3Atab%22&type=code