0

The character with code 0x1B (generated by Ctrl+[) is not meant to be used directly by applications, because it was designed to serve as the signal which starts a control sequence. I never input control sequences by hand (does anybody do?), thus I do not need any keybinding to produce the escape code itself. So, I would prefer to use these buttons for something else. You see, these two buttons (Ctrl and [) occupy a convenient place on the keyboard and are thus convenient to type, and it's a pity that this keybinding is just wasted.

How do I make Ctrl+[ generate the control sequence of my choice? (both under X and under Wayland)

  • 1
    Ctrl+[ here is an alternate way of inputting Escape and is supplied by the terminal driver, not XKB (the keyboard-config layer in both modern X11 and Wayland). stty will let you query and set terminal settings, but i dunno how you'd change that one without breaking things like ... the terminal. XKB would allow you to remap a Ctrl key to a modifier (eg Alt, Hyper, or Super), but then it wouldn't act like a Ctrl key anywhere, which might not be what you want. see https://en.wikipedia.org/wiki/C0_and_C1_control_codes https://en.wikipedia.org/wiki/ANSI_escape_code – quixotic May 30 '17 at 03:01
  • (you may not be manually entering control sequences, but those characters are what allow ANSI colors in your shell prompts and curses libraries.) – quixotic May 30 '17 at 03:03
  • @quixotic right, and for colors to work there need not be a keybinding on keyboard which generates the escape code (0x1B). I wonder how changing a keybinding may break the terminal – Igor Liferenko May 30 '17 at 03:22
  • see https://unix.stackexchange.com/a/243651 for a better explanation of the various layers of terminal handling. (these are not keybindings in the same way that Ctrl+C/Ctrl+V doing Copy/Paste in your browser are keybindings.) – quixotic May 30 '17 at 03:23
  • Translating from keychords to escape sequences is the job of the terminal emulator. Which terminal emulator are you using? It's also possible to remap Ctrl+[ to something like Ctrl+F13 with XKB, but even then some terminal emulators may not have an escape sequence for it. And there's a terminal feature that allows terminal applications to distinguish between Ctrl+[ and ESC but it only works in a few terminal emulators and not all applicatoins can cope with it. – Gilles 'SO- stop being evil' May 30 '17 at 23:12

0 Answers0