How do I bind the keys Tab and ShiftTab in screen? My problem is that I don’t know what to pass to the screen bind command to designate these keystrokes.

BTW, I’m aware of GNU screen: move between regions but the answer is not there.

All of the following fail with the error -X: bind: character, ^x, or (octal) \032 expected:

screen -X bind "\033[Z" focus up
screen -X bind "^[[Z" focus up
screen -X bind "\t" focus up
screen -X bind \033[Z focus up
screen -X bind ^[[Z focus up
screen -X bind \t focus up

Same thing if I hit CtrlA: to input the command.

  • @StephaneChazelas I would agree, except that: 1) other people might find this question useful if they're looking for this particular case; 2) I still couldn't find exactly what to pass to bind to make this work - see (upcoming) edit
    – ricab
    Commented Oct 25, 2013 at 13:52
  • OK, retracting the close vote since it's a newer question now. Unfortunately, the way SE works, unless all the other closers retract their close votes, it's likely to end up being closed... Commented Oct 25, 2013 at 14:37
  • Please reopen, that was me closing it by mistake. Commented Oct 28, 2013 at 15:12
  • @StephaneChazelas: something I should do to reopen?
    – ricab
    Commented Oct 28, 2013 at 16:16
  • Nope. Wait for enough people with enough reputation to vote for reopen, like for the closing. Commented Oct 28, 2013 at 17:31

2 Answers 2


Contrary to bindkey where you can specify character sequences, with bind, the only way is by using bind -k CAP where CAP is a termcap key capability.

For instance,

bind -k ku focus up

works to bind the sequence of character sent upon Up to focus up. For backtab, that should be:

bind -k kB focus up

Unfortunately, for some reason, it doesn't see to work. Not sure why. My first interpretation was wrong. It sounds like it has something to do with with ncurses not handling the termcap equivalent of kcbt correctly:

$ infocmp -1 | grep Z
$ infocmp -1C | grep Z

(kcbt is no translated to kB).

If I add to my ~/.screenrc:

 termcapinfo * kr=\E[Z
 bind -k kr focus up

That is, if I tell screen that whatever the host termincal (*), F63 (kr) sends \E[Z, and bind F63 to focus up, then that works. However note that pressing Shift+Tab now sends within screen \EOC, which is the character sequence that the terminal emulator that screen implements (as opposed to the host terminal) sends upon F63.

  • I didn't quite get this answer and it didn't work for me. bind doesn't have a -k option here (at least not documented). I get also "character, ^x, or (octal) \032 expected" with your bind cmds. But thanks for the help anyway
    – ricab
    Commented Oct 28, 2013 at 14:02
  • OK I figured you probably meant bindkey instead of bind. Tried that and it now Shift+TAB does focus up. But not after Ctrl+A as with tab, so it is still no symmetric. I basically wanted to have C-a shit-tab be the symmetric of the default C-a tab
    – ricab
    Commented Oct 28, 2013 at 14:09
  • 1
    @ricab, bind -k works for me though it's not documented (4.01.00devel) Commented Oct 28, 2013 at 15:11
  • Interesting, it does not work here (4.00.03 (FAU)). I get the error bind: character, ^x, or (octal) \032 expected
    – ricab
    Commented Oct 28, 2013 at 16:19
  • 1
    regarding "(kcbt is no translated to kB)." -- that's probably because the termcap was trimmed to fit in 1023 bytes (expected behavior). Commented Dec 20, 2018 at 2:24
bindkey -k kB stuff ^[OZ
bind -k kB focus up

In my case the problem is that the string inserted when I press Ctrl+A - Shift+Tab is ^[[Z after Ctrl+A which translates in

  • ^[ enter copy/scrollback mode
  • [ abort
  • and then show Z

i.e. the standard VT100 style escape sequence of characters is in conflict whit copy/scrollback mode character sequence. So I added a key binding for the backtab termcap name kB to change the string inserted in the input buffer when Shift+Tab is pressed to ^[OB.

See the "INPUT TRANSLATION" section in the screen man page.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .