Application-specific default keyboard layout in Mac OS X

243

Solution 1

I think the easiest solution is to add a bit of manual work and do it as follows:

  • Turn on the languages you want in System Prefs > Language & Text > Input Sources
  • Under "Input source options" select the "Allow a different one for each document"
  • Set up a keyboard shortcut to change keyboard layout
  • Launch your app, change your keyboard layout, and it will only be changed for that window.
  • If you bring up a new firefox window, you'll need to re-select the language for that new window.

To answer your specific desire to have apps open in one layout:

  • Set the "Allow a different one for each document" as directed above.
  • Find out how to change the layout via script. Solutions seem available...
  • Make a new launcher (AppleScript) for Firefox that launches Firefox, then runs the keyboard changer after a delay (when you are sure Firefox is open and in front).
  • Perhaps this is good enough as doing it at launch meets your needs. If not, run it continuously as @pattern86 suggested

Solution 2

I suggest you to try Keyboard pilot.

The app is sold in Mac OS App Store for a small price. It allows you to set a list of app->layout pairs which forces active layout to change when the specified app gains focus.

Solution 3

The top-voted answer is outdated! There is no such option for Yosemite.

I found great and free application, that resolve this issue: Auto Keyboard

By this app you can specify default language for any specific app - simply awesome!

Solution 4

I suggest you to try Keyboard Maestro at https://www.keyboardmaestro.com/main/.

By this app you can specify default input source for any specific app - simply awesome!

Check my screenshot:

enter image description here

Solution 5

You can write an Applescript that constantly runs and checks if an app has focus and if it does then it sets the keyboard layout to one layout and when it detects that the app doesn't have focus it switches the layout back again. Have it run at login.

I can't help with writing the app, but that would be the solution.

Here are a couple of related articles that I found:

Share:
243

Related videos on Youtube

echo_Me
Author by

echo_Me

Updated on September 17, 2022

Comments

  • echo_Me
    echo_Me over 1 year

    Let's say I have these two related arrays:

    $letters = ['a', 'b', 'c', 'd', 'e'];
    $replace = [1, 5, 10, 15, 20];
    

    And a string of letters separated by spaces.

    $text = "abd cde dee ae d";
    

    I want to convert consecutive letters to their respective numbers, sum the numbers, then replace the original letters with the total.

    Using str_replace() isn't right because the values are compressed as a string before I can sum them.

    $re = str_replace($letters, $replace, $text);
    echo $re;  //this output:
       
    1515 101520 152020 120 15
    

    I actually want to sum the above numbers for each "word" and the result should be:

    21 45 55 21 15
    

    What I tried:

    $resultArray = explode(" ", $re); 
    
    echo array_sum($resultArray).'<br />';
    

    It incorrectly outputs:

    255190
    

    EDIT:

    My actual data contains arabic multibyte characters.

    $letters = array('ا', 'ب','ج','د' ) ;
    $replace = array(1, 5, 10, 15 ) ;
    $text = "جا باب جب"; 
    
  • slhck
    slhck over 11 years
    Hi Gleb! Could you please expand your answer and explain how it solves the problem, what it does, etc.?
  • Ory Band
    Ory Band over 11 years
    Thank you! I've looking for a way to do this for a couple months now. Safari would always switch the keyboard layout on its own, drove me nuts.
  • echo_Me
    echo_Me about 11 years
    edited my answer look what it output . it output this 255190
  • echo_Me
    echo_Me about 11 years
    this outputs as an array not as i wished.
  • Michael
    Michael about 11 years
    OK, I've changed to echo it as space-separated numbers.
  • Joe F
    Joe F about 11 years
    I apologise, I meant str_split not explode - and $sums[-1] is meant to be the last index not the -1th, let me fix that....
  • echo_Me
    echo_Me about 11 years
    thanks , but michael was first who solve it , i appreciate your fix also , +1
  • Michael
    Michael about 11 years
    Can you show me an example with Arabic letters in the question?
  • Michael
    Michael about 11 years
    You probably need to enable mbstring: php.net/manual/en/mbstring.installation.php
  • echo_Me
    echo_Me about 11 years
    ok i fixed it here php.net/manual/en/function.mb-split.php thanks again, the problem was the split
  • Guillermo Siliceo Trueba
    Guillermo Siliceo Trueba over 10 years
    I had this same problem, and went ahead and bought keyboard pilot and it indeed solved the problem, it just switches the layout when you switch applications.
  • skywinder
    skywinder about 9 years
    This answer is outdated! There is no such option for Yosemite. check mine answer: superuser.com/a/889096/230571
  • Evmorov
    Evmorov almost 8 years
    Maybe once it was free but now it's not
  • Alissa
    Alissa almost 7 years
    Punto switcher is a small utility, basic functionality of it is fixing text typed in wrong layout. It also can remember layout per application. And it's not a plugin for some other app, it's a standalone tool... I don't see how it 'depends on the application itself'.
  • MKT
    MKT about 6 years
    The option is now back in OS X High Sierra, but rephrased to "Automatically switch to a document's input source". I found that very useful.
  • Andrey Semakin
    Andrey Semakin over 4 years
    And now it's even not available, or maybe it just for my region...
  • user14492
    user14492 over 3 years
    Exactly what I wanted. KM is a multi-edged sword.
  • Alice Purcell
    Alice Purcell over 3 years
    Still available and seems to be free now! Nice, thanks!