1

I am using a Danish keyboard language and Danish keyboard layout. When typing in my browser or other applications on my computer, I can make a backslash. In my case I use the combination shift + option + /. However, when I enter the terminal (either through VSC or directly from my computer), I can't make backslash through the key combination. Nothing happens. I am using bash.

I have also tried the Z shell instead, but I can't make backslash there as well. For similar characters I can use their key combinations without any problems in the bash terminal. E.g. shift + option + ( makes an opening curly bracket '{'.

Thus, the key combination for backslash works fine in browser and applications, but not in the terminal. Is there a way to add a new key combination for the terminal?

2
  • @user1934428 Correct. In pages, browser, textedit, or any other applications I have tried, I can make backslash. However, a slight update on the terminal.app (which makes it more weird): when I open terminal.app I can make backslash now. However, if I open a new terminal window from within the terminal.app, I suddenly can't make backslash. And also when I access terminal through VSC (the editor I use), I also can't make backslash.
    – morten
    Commented Jun 5 at 14:22
  • Out of curiousity: How do you open a new terminal window from within terminal app, and what's the point in doing so? Commented Jun 6 at 6:11

2 Answers 2

0

If you have set your terminal to treat the "option" key as "meta" key, it will send ESC(0x1b, \e)-prefixed ASCII sequences to the shell instead of going through keylayout translations. E.g. option+a becomes ESC a. In macOS preinstalled Terminal.app you can toggle this preference with a menu bar item called "Use Option as Meta key". I don't know if a similar toggle exist in VSCode's xterm.js. If you want to insert \ without disabling option-as-meta, you can set a key sequence binding in your shell to insert "\" when received ESC /. I don't have a mac with me to verify my answer, but it should work.

0

Below is an image of a Danish Magic Keyboard with Touch ID and Numeric Keypad for Mac models with Apple silicon.

Danish Numeric

Under the Terminal Application preferences, you can set ⇧ (shift)+option+/ to produce the \ character, where / is the key on the numeric keypad shown above. See image below.

enter image description here

You may choose a difference key and modifier, if you wish.

If you do not have a numeric keypad, then see below.

Below is an image of a Danish Magic Keyboard with Touch ID for Mac models with Apple silicon.

Danish

Under the Terminal Application preferences, you can set ⇧ (shift)+fn+F4 to produce the \ character. See image below.

enter image description here

You may choose a difference key and modifier, if you wish.

You must log in to answer this question.

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