Is there any way to assign hotkeys to switching to particular keyboard layouts directly, without having to cycle through them one by one?
I am quite new to OS X. On Windows (which I used before) it is possible to set keyboard shortcuts for witching directly to particular keyboard layouts. For example, I set it up so that Shift–Alt–1 switches directly to English, Shift–Alt–2 switches directly to Hungarian, etc. This is very convenient when one has several layouts installed (I regularly used 4 different ones on Windows), and much faster than having to cycle through layouts one by one, especially when writing multilingual documents and needing to switch often.
Is there similar functionality in OS X? If there's isn't by default, is there a hack or third party program to set it up?
Best Answer
Command Line Utility + System Service
This is a two-part solution: first a means of changing the keyboard layout, and then a means to activate that by a keyboard shortcut. But it's fairly easily accomplished.
1. Changing the Layout
To change the layout programmatically, there's a handy (and free) little utility called
changeInput
, which you can download here.Download and unzip it, and place the
changeInput
executable somewhere. Be sure to note the path for the second section.2. Creating Keyboard Shortcuts
There several ways to do this, but to make things accessible for anyone, we'll do it with built-in tools by making a System Service with Automator.
/path/to/changeInput "Name of Layout Here"
. Be sure to enter the exact path tochangeInput
as you saved it (tip: you can drag the executable right into the text field to get the proper path). Replace"Name of Layout Here"
with the exact text that's displayed in the Input Sources section of System Preferences or the Input Menu — be sure to keep the quotes.~/Library/Services/
.As an alternative to using the Automator/Services combo to create the keyboard shortcuts, you can use FastScripts, the free version of which allows you to quickly set keyboard shortcuts for 10 scripts, or $14.95 for an unlimited number. Keyboard Maestro can also easily run a script with a keyboard shortcut, but it's a bit overkill if this is your only need (it is worth checking out for lots of other scripty/powerusery type things).