MacOS – OSX Lion: Long press menu automatic selection

internationalizationkeyboardmacos

I've recently upgraded to OSX Lion and I find the long press menu with accented characters very handy when I have to type in french. The only problem is that it's slowing me down a lot having to long press THEN select which character I'd like to have.

Therefore I'm looking for a way to automatically select the first option if another key is pressed. Example: the first option for "c" is ç but I have to long press then press 1 to get it. The behaviour I'm looking for is when I'm typing the word "ça" I don't have to press 1, I just long press "c" and type "a" but because I long pressed the key I get a "ç" and the word "ça".

Other questions have been concerned with changing characters in the popup list but I didn't find any concerning this. Is there an option I missed? Do you have any leads on how I could obtain such a behaviour (it doesn't matter if it involves programming or fiddling with the command line)?

Best Answer

UPDATE: I misunderstood your question and the answer is you can't. The way it works is kinda lame but i haven't found a way to change that.

They way I do it, is I long press the key and then use the right arrow key to select the one I want, so a single right arrow key will put you in the first item. But then again, this is not the "automatically insert the first one when i long press" option that you want.

I will leave the rest of the answer just because it was too much writing and it may be useful for someone :-D

-----------------------------------------------------------------

The only solution for this is to alter the order of the chars in the corresponding language. If you're "familiar" with the Terminal, you can find how to do that in this answer.

Quoting:

The characters included in the popovers are defined in property lists inside the /System/Library/Input Methods/PressAndHold.app/ bundle.

I was able to change à to y by editing /System/Library/Input Methods/PressAndHold.app/Contents/Resources/Keyboard-en.plist and logging out and back in.

So, you should open Terminal.app, and type:

cd /System/Library/Input\ Methods/PressAndHold.app/Contents/Resources/

Then, perform an ls to see the contents:

ls -l

And find one that looks like the keyboard layout you're using (I'm assuming french) so it should be Keyboard-fr.plist

Backup the file now to your Desktop just in case:

cp Keyboard-fr.plist ~/Desktop

Finally, edit the current file by doing:

sudo vi Keyboard-fr.plist

this is going to prompt you for your password, the reason is that the file is protected so you need to be an admin. Type your password and press enter. The vi editor should open with the contents of the file.

If you scroll down (use the arrow keys), you will find this:

<key>Roman-Accent-c</key>
 <dict>
  <key>Direction</key>
  <string>right</string>
  <key>Keycaps</key>
  <string>ç c ć č</string>
  <key>Strings</key>
  <string>ç c ć č</string>
 </dict>

There are two key pieces here:

  1. you can see that this corresponds to the lower case 'c' because it says: "Roman-Accent-c". If you wanted to modify 'a' you should find "Roman-Accent-a". You can even create new ones, like Roman-Accent-Q will be for upper case 'Q'. (so the popup will appear if you press-and-hold shift-Q. Neat huh?

  2. You can see the sequence of chars: ç c ć č

There is a space between each char (you can add more, I don't know if there's a limit, I have one with 14).

Please note that you have to change it in both lines

I assume you're familiar with the 'vi' editor, but if you don't know how to do it, here's a 5 seconds crash course for this task.

Once you are positioned (using arrows) where you want to edit (i.e.: the cursor is over the ç in the line), press "i" to enter insert mode. now retype your chars in the order you want them and delete the ones you don't want (move with the arrows if unsure, delete with "delete" key). It's a bit tricky. Repeat the above for the other line below, they must look alike.

Once you're done and happy, press (That's the esc key) to exit insert mode, then type:

:wq

Yes, that's a semicolon, then a "w" and a "q" (for write, quit), then press enter.

You should be back at the terminal.

If you get a -- INSERT -- W10: Warning: Changing a readonly file or similar when you press "i" to INSERT, you forgot to do the sudo command and you have no permission to write to the file, so don't waste time and try to fix that first :)

If for some reason you mess up, don't panic. You can always exit insert mode at any time (by pressing esc) and then 'u' to UNDO or :q! (semicolon, q + !) to quit without saving.

Anyway, once you have saved your results, logout or restart your computer and you should be set to go.

Good luck :)