Typing the control+\ (backslash) on Apple keyboard

keyboardterminal

I've been trying for quite some time now to figure out how I'm supposed to type the escape sequence '^\', Control+Blackslash on a Mac.

I have a Swedish keyboard with the Swedish Pro layout, and I have backslash on Shift+Alt+7, but pressing Ctrl+Shift+Alt+7 just gives me a 7, not the escape sequence I would expect.

The closest thing I found while googling is: How do I send C-/ (that is, control-slash) to the terminal?

But it doesn't give away how to do the Control+Backslash, any ideas?

Best Answer

As a user of the Danish Apple keyboard, I face similar issues. Most of the time I — unfortunately — have to remap keyboard shortcuts through System Preferences > Keyboard > Shortcuts. I researched a bit and wasn't able to find the native way to do this combo on a Scandinavian keyboard.

However, you might be able to create a service through Automator that presses the keyboard combination for you:

  1. Open Automator
  2. Create a new document and select Service as type
  3. Set Service receives selected to no input
  4. Drag out a Run AppleScript action from the left pane
  5. Replace (* Your script goes here *) with tell application "System Events" to keystroke "\\" using {control down}
  6. Save and call the service whatever you deem appropriate

Then try running it at a time when you need to press Ctrl+\ (For Terminal: Terminal > Services > Name of Your Service).

I'm not currently able to test this but it might be worth a try.