Apple - How do I send C-/ (that is, control-slash) to the terminal?
Control-/
is not a part of the set of standard control codes. It is not directly representable as a keystroke in many terminal emulations. Such a keystroke is only properly detectable in certain platform-specific “scancode modes” or “GUI mode” (where the API tells you exactly which keys and modifiers are being used). Your terminal emulator is beeping because it is effectively an invalid keystroke.
The standard control codes only cover “Control” versions of
@
A
–Z
[\]^_
(ASCII 0 - 31), and?
(ASCII 127)
In most terminal emulator programs running with most US key layouts you may need to press Shift to generate some of the “Control codes”:
- C-@ is ControlShift2 (since
@
is Shift2) - C-^ is ControlShift6 (since
^
is Shift6) - C-_ is ControlShift- (since
_
is Shift-) - However, C-? may not always be ControlShift/ (since
?
is Shift/); C-? is usually generated by either Backspace (on Apple keyboards, the key labeled just “delete” without the additional symbol ⌦) or Delete (the one with ⌦ on Apple keyboards).
In tty-based Emacs, you can usually use C-_ for undo
instead of C-/.
Ctrl-/ sends 0x1f which is equivalent of Ctrl-_ since the days of VT102. There are many VT100 emulators but they are actually VT102 emulators. iTerm2 works because it's following this behavior.
Only emulators that strictly conform to VT100 specification can't send Ctrl-/. I believe the Terminal app is one of them.
VT100 masks 2 most significant bits of 7 bit ASCII when the control key is pressed. / is 0x2f, o is 0x6f. When the 2 bits are masked they are both 0x0f. VT100 can send Ctrl-o but not Ctrl-/.