Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

Terminals transmit characters (more precisely: bytes), not keys. When you press a key or a keychord like Ctrl+;, this information has to be encoded into a sequence of bytes. Keychords that represent a character, like A or Shift+A or À, are sent as that character: a, A, à (the last one being one or two bytes depending on the terminal's character encoding).

Keychords involving function keys have no corresponding character, so they are sent as escape sequences: a sequence of bytes beginning with the escape character (\e in an Emacs string, appearing as cyan ^[ if entered literally in a buffer). A few function keys have corresponding bytes which are control characters.

The keychord Ctrl+; has no standard escape sequence, so most terminal emulators generate the character ;. This loses the information that the Ctrl modifier was pressed.

In order to define a binding for Ctrl+;, you'll need to configure your terminal emulator to send a different escape sequence. I don't think you can do this with Gnome terminal (Gnome is rarely configurable). You can do it with Xterm. See Are there any linux terminals which can handle all key combinations?Are there any linux terminals which can handle all key combinations? for instructions.

The shell that you may run in the terminal is not involved. A GUI Emacs has no problem because the GUI (X11) transmits input events in a form that encodes keys and modifiers, not as a mere sequence of characters.

See How do keyboard input and text output work?How do keyboard input and text output work? for more detailed background on how input gets from your keyboard to your application.

Terminals transmit characters (more precisely: bytes), not keys. When you press a key or a keychord like Ctrl+;, this information has to be encoded into a sequence of bytes. Keychords that represent a character, like A or Shift+A or À, are sent as that character: a, A, à (the last one being one or two bytes depending on the terminal's character encoding).

Keychords involving function keys have no corresponding character, so they are sent as escape sequences: a sequence of bytes beginning with the escape character (\e in an Emacs string, appearing as cyan ^[ if entered literally in a buffer). A few function keys have corresponding bytes which are control characters.

The keychord Ctrl+; has no standard escape sequence, so most terminal emulators generate the character ;. This loses the information that the Ctrl modifier was pressed.

In order to define a binding for Ctrl+;, you'll need to configure your terminal emulator to send a different escape sequence. I don't think you can do this with Gnome terminal (Gnome is rarely configurable). You can do it with Xterm. See Are there any linux terminals which can handle all key combinations? for instructions.

The shell that you may run in the terminal is not involved. A GUI Emacs has no problem because the GUI (X11) transmits input events in a form that encodes keys and modifiers, not as a mere sequence of characters.

See How do keyboard input and text output work? for more detailed background on how input gets from your keyboard to your application.

Terminals transmit characters (more precisely: bytes), not keys. When you press a key or a keychord like Ctrl+;, this information has to be encoded into a sequence of bytes. Keychords that represent a character, like A or Shift+A or À, are sent as that character: a, A, à (the last one being one or two bytes depending on the terminal's character encoding).

Keychords involving function keys have no corresponding character, so they are sent as escape sequences: a sequence of bytes beginning with the escape character (\e in an Emacs string, appearing as cyan ^[ if entered literally in a buffer). A few function keys have corresponding bytes which are control characters.

The keychord Ctrl+; has no standard escape sequence, so most terminal emulators generate the character ;. This loses the information that the Ctrl modifier was pressed.

In order to define a binding for Ctrl+;, you'll need to configure your terminal emulator to send a different escape sequence. I don't think you can do this with Gnome terminal (Gnome is rarely configurable). You can do it with Xterm. See Are there any linux terminals which can handle all key combinations? for instructions.

The shell that you may run in the terminal is not involved. A GUI Emacs has no problem because the GUI (X11) transmits input events in a form that encodes keys and modifiers, not as a mere sequence of characters.

See How do keyboard input and text output work? for more detailed background on how input gets from your keyboard to your application.

Source Link
Gilles 'SO- stop being evil'
  • 865.4k
  • 205
  • 1.8k
  • 2.3k

Terminals transmit characters (more precisely: bytes), not keys. When you press a key or a keychord like Ctrl+;, this information has to be encoded into a sequence of bytes. Keychords that represent a character, like A or Shift+A or À, are sent as that character: a, A, à (the last one being one or two bytes depending on the terminal's character encoding).

Keychords involving function keys have no corresponding character, so they are sent as escape sequences: a sequence of bytes beginning with the escape character (\e in an Emacs string, appearing as cyan ^[ if entered literally in a buffer). A few function keys have corresponding bytes which are control characters.

The keychord Ctrl+; has no standard escape sequence, so most terminal emulators generate the character ;. This loses the information that the Ctrl modifier was pressed.

In order to define a binding for Ctrl+;, you'll need to configure your terminal emulator to send a different escape sequence. I don't think you can do this with Gnome terminal (Gnome is rarely configurable). You can do it with Xterm. See Are there any linux terminals which can handle all key combinations? for instructions.

The shell that you may run in the terminal is not involved. A GUI Emacs has no problem because the GUI (X11) transmits input events in a form that encodes keys and modifiers, not as a mere sequence of characters.

See How do keyboard input and text output work? for more detailed background on how input gets from your keyboard to your application.