Customization of keyboard from the Terminal. Is it possible?

I have a question for Unix/MacOS connoisseurs. Can you change the settings of just ONE key on the keyboard, without altering the others? How can I customize the keyboard in such a way that this setting remains universal to all programs that Mac uses?

This is my problem: I work with LaTeX almost daily in several languages, mainly English, but also and frequently in Spanish and French. I am also relearning some coding stuff, due to my research in applied mathematics. So I need to have the backslash symbol \ without having to change the rest of the symbols on my keyboard, such as "ñ" or "ç".

Mac has a function to replace text on the keyboard, I've already used it and it works fine for text editors like Pages, but, unfortunately, it doesn't go well for coding or editing LaTeX docs. When I work in the Terminal, with Option+Y it writes the \ , but if I do the same with the LaTeX editor, it prints a ¥. The same thing happens when I work in R with any other mask than the Terminal.

The most obvious solution to this problem is to change the keyboard language every time you need to use the \ symbol, but this isn't practical when you're editing a LaTeX document and working on some code at the same time.

What can I do? Where can I find some information?

Thanks in advance.

Yes, you can do this with terminal settings and terminal profiles. I create custom terminal profiles and it works fine for me.

See, for example, in Terminal app on macos:

2 Likes

Thanks. I have tried it, as you suggested. It's fine for working on terminals and it will save me some time. Nevertheless, the main problem I have is still the same: this customization is not universal. As soon as I switch to a different program, the keyboard recovers its "particular" features. Of course, I can work LaTeX form a terminal, but this implies I will lose the editor's text highlighting, plus I'm going to have to manually invoke the compiler.

If Shift-7 is a / slash, then Alt-Shift-7 should give a \backslash.

I do not understand this statement above.

When on macos, and working in command line (Terminal) environment, the keyboard mappings are controlled in the profile of the Terminal profile. This does not change according to the application; it changes according to the created Terminal profile. You can create as many Terminal profiles as you need and when you have an application which requires a certain Terminal profile (keyboard mapping) you just open the app in a Terminal set up for the app keyboard requirements.

Sorry, @Gabo , but your words trying to describe your problem do not make any sense to me; a daily macos user. Invoking any application from the command line of a custom Terminal profile will not necessarily effect application syntax highlighting, however it could I guess, but this should not be a surprise because when on macos, we use the Terminal application for command line work.

If you don't like Terminal, the default macos app for the command line, why not try others, like this one:

Or maybe experiment with one or more terminal emulators from this list:

Here is the answer from ChatGPT. Maybe I should create a new user called "ChatGPT" and write a plugin to let ChatGPT help out? :slight_smile:

It is possible to customize the behavior of individual keys on your Mac keyboard, but it will require using the macOS software development kit (SDK). The SDK includes tools and resources for developing custom keyboard layouts that you can use to change the behavior of individual keys.

To create a custom keyboard layout, you will need to use the Keyboard Layout Editor included in the macOS SDK. This editor allows you to create a new keyboard layout by modifying an existing layout or starting from scratch. You can then specify the desired behavior for each key on the keyboard, including the backslash key.

Once you have created your custom keyboard layout, you can install it on your Mac and switch between it and your other keyboard layouts as needed. You can also set your custom layout as the default layout if you want it to be used whenever you are using a particular program or set of programs.

To learn more about creating custom keyboard layouts on macOS, you can refer to the documentation provided in the macOS SDK. This will provide more detailed instructions on using the Keyboard Layout Editor and installing your custom layout on your Mac.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.