-
Notifications
You must be signed in to change notification settings - Fork 372
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
How to handle ctrl + Arrow keys input using termbox-go? #60
Comments
Termbox doesn't support them. Any unknown esc key sequence (ctrl+arrow keys are esc seqs) is recognized as esc and characters which follow. The reason for this is that termbox supports only a common subset of functionality all most popular terminals support. There is no way to avoid that behaviour, unless you simply ignore esc. I've said that many times and I'm happy to repeat: terminals suck when it comes to input, you have to live with it or use something else than a terminal. That's why editors like vim and emacs have a very restricted set of bindings by default. Both vim and emacs don't even use arrow keys mainly and recommend to use other keys (C-f C-b C-n C-p or hjkl). Yes, they do support it eventually, but as I said, not all terminals handle ctrl+arrow keys properly. I'm strongly against building interfaces which aren't portable (i.e. don't work on all platforms). Yes, termbox became already that kind of a library, where on linux there are 256 colors and on windows there is no such thing. Initially termbox was born because I tried doing portable stuff (linux and windows) using some w32 curses port and it simply didn't work well. So, whatever, I don't know what to do about it. |
Control+Arrow can't work on most terminals -- there is no escape sequence defined for it, and so its generally impossible outside of Windows. |
Control+arrow works on all terminal emulators I've tried (on Linux) and it's supported in programs like vim. Can these keys be added to termbox-go so it's easy to work with? |
Termbox is no longer maintained, you can try this lib: https://github.com/gdamore/tcell It might support what you're looking for. |
Can you please explain how one can handle "Ctrl + ArrowX" keys where X=Up, Down, Left, Right? Currently, my app using termbox-go just quits as soon as I hit Ctrl + any Arrow key, and so are most of the _demos/.go sample programs, except keyboard.go. Any documentation or explanation around it will be quite useful. Ideally, I would like to either handle it and take some action or at least make sure, my app doesn't just quit when user hits this key combination.
The text was updated successfully, but these errors were encountered: