Junius L
Junius L

Reputation: 16152

ASCII codes for Ctrl-Up and Ctrl-Down

I'm implementing a small shell in C and I want to use Ctrl-Up and Ctrl-Down. Are there ASCII codes for Ctrl-Up, Ctrl-Down and Ctrl-Shift+C? I have searched everywhere for them and I couldn't find them.

Upvotes: 0

Views: 1139

Answers (1)

Paul J. Lucas
Paul J. Lucas

Reputation: 7151

As @MateoConLechuga mentioned, what you're looking for simply doesn't exist. What actually happens when you press Ctrl-Up is that the terminal sends a special sequence of characters starting with the ESC character. For example, on my terminal, Ctrl-Up sends ESC[1;5A.

What you need to to is use something like the ncurses and/or the termcap libraries to deal with things like terminal input in a terminal-independent manner.

Unfortunately for you, this is probably way more work that you were hoping for. Writing a "small" shell is non-trivial.

Upvotes: 2

Related Questions