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

How to handle ctrl + Arrow keys input using termbox-go? #60

Open
acmeofevolution opened this issue Dec 30, 2014 · 5 comments
Open

How to handle ctrl + Arrow keys input using termbox-go? #60

acmeofevolution opened this issue Dec 30, 2014 · 5 comments
Labels

Comments

@acmeofevolution
Copy link

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.

@nsf
Copy link
Owner

nsf commented Dec 30, 2014

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.

@nsf
Copy link
Owner

nsf commented Feb 15, 2015

I'm adding raw events to the termbox. See: #65

And the commit: 54b74d0

Technically, it's a way to handle Ctrl+Arrow keys. Maybe not the best one, but it is.

@nsf nsf added the Info label Mar 23, 2015
@gdamore
Copy link

gdamore commented Sep 21, 2015

Control+Arrow can't work on most terminals -- there is no escape sequence defined for it, and so its generally impossible outside of Windows.

@Limero
Copy link

Limero commented Jul 22, 2019

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?

@nsf
Copy link
Owner

nsf commented Jul 22, 2019

Termbox is no longer maintained, you can try this lib: https://github.com/gdamore/tcell

It might support what you're looking for.

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

No branches or pull requests

4 participants