Key Bindings in Spanish keyboard not working as expected

When using a MacBook Pro with the Spanish keyboard (Spanish - ISO) the key bindings for Comand Shortcuts don't work as expected. Usually, they perform the action of another command. For example, Move Line Up, which is command + option + [, actually performs Shift Right (command + [). Some other Command Shortcuts like Run Playground (shift + command + enter) do work.



It is important to note that some commands are also difficult to perform because their keys can't be reached without using alt or shift, yet these last keys are not mentioned in the Key Bindings for that command. For example, Size to Fit Content is command + =, but in the Spanish - ISO keyboard the equal sign "=" is accessible only through shift + 0. so the Key Binding for Size to Fit Content should be command + shift + 0.



In Preferences > Key Bindings there are some conflicts (21 in total), but none of these include the Shortcut Commands that are showing unexpected behavior.



In summary, Key Bindings are not working in the Spanish - ISO keyboard because they seem to be configured for the US English keyboard only. This is producing some unexpected results and is hindering developers with other keyboards that are not the US English.

Did you look how to redifine to meet your needs in XCode preferences ?

I tried creating a new Key Bindings from the default ones. I switched some key bindings, they were working fine, but then others where showing unexpected behavior. Specifically, I changed Move Line Up / Down to command + alt + up / down. Then these commands worked fine, there were no conflicts with other shortcuts. But then I tried Shift Right (command + [), and it was changing the font-size, even though in preferences (and also in the Structure menu) it was listed as Shift Right command + [. I hope I don't have to redefine every command I use, and then find more and more unexpected behaviors in other commands I didn't redefine.

Hello, today I had the same problem after updating the OS to Monterey. Here is how I solved it.

First, the characteristics of my set-up were as follows:

  • Xcode version: 13.1 (13A1030d)
  • OS: macOS Monterey 12.2
  • Keyboard input: Spanish Latin American
  • Keyboard physical Layout: ANSI US English (of MacBook Air bought in Japanese market)

The problem occurred when trying to "comment" a section of code. But the usual key combination of Cmd + Shift + 7, which was always interpreted as Cmd + / did not work. So for the explanation, I will treat the case of the key binding "Cmd + /" not working in my not-US keyboard input.

Solution:

1 . In Xcode -> Preferences -> Key bindings search: command / to find all commands associated with the key combination.

2 . Change the key combination of one of the 4 occurrences to any combination you wish (The rest will update automatically when you click outside of textbox). This will modify the Key bindings file on your computer. Doesn't matter if you cause a conflict.

3 . Close Xcode and open the Defaults.idekeybindings file in the directory (user)/Library/Developer/Xcode/UserData/KeyBindings with your preferred text editor. (Library directory is hidden. If you want to access from Finder press Cmd + Shift + . to see hidden files).

4 . In the file content we can see 4 < dict > structures and in each of them, inside one < string > tag is the key combination we entered previously. The codification is easy to understand since "$" resembles S from Shift and "@" has curves like the Cmd symbol. I assume this documentation is still valid, so the rest special key's codes should be "^" and "-".

5 . Replace the key combination in every < dict > structure for the literal key combination you have always used. In this case, I will insert Cmd + Shift + 7 in that order since Shift + 7 is interpreted as "/" everywhere (but when combining with Cmd in Xcode).

6 . Save the file, exit the editor, open again Xcode and you should have your key combination working!

NOTE: If you wondered why I did not simply insert the combination Cmd + Shift + 7(number) in the Key binding window is because if I type that combination, Xcode will register Shift + Cmd + / instead. Definitely is something they have to correct since ONLY for the case of typing Cmd + Shift + 7 (Cmd + /) and Cmd + Shift + 0 (Cmd + =) the program decides to register this other pattern. For the rest of the numbers, it will register the combination correctly! E.g. if I want to register Cmd + &, with my keyboard I have to type Cmd + Shift + 6, and in the Key Combination textbox it will appear Cmd + & as anyone would expect! Weird behavior.

  • Trying to register Cmd + / :

  • Registering Cmd + & :

NOTE 2: I will check how to report this and possibly have an explanation of this behavior or a reply taking on the commitment to fix this. Because users having to make workarounds for this kind of sudden change in behavior of a program you have used daily is really a pain in the neck and today I interrupted the flux of my work to get Xcode to work as before.

Cheers,

Franz

Update:

Found other discussions about the same topic, so nothing new with the workaround. Anyways, hope the thorough explanation results useful for someone.

In these other discussions, someone mentioned that for Xcode 13.2 the usual behavior is back.

Xcode 13.1: What happened to shortcuts on international keyboards?

Xcode 13 key bindings problems

Key Bindings in Spanish keyboard not working as expected
 
 
Q