A number of people, myself included, have tried out alternative keyboard layouts such as Dvorak and Colemak. Surprisingly, operating systems have already started to include them as native keyboard layout options. I've been using alternative keyboard layouts for the past 8 years or so: the first 6 years I used Dvorak, and I recently switched to Colemak in the last couple of years.
Personally, my reasons for switching have been due to ergonomics, and a little bit can probably just be attributed to me wanting to be a special snowflake. In my experience, I have run into a few issues when switching. There is an initial cost of learning the new layout, which can be painful if you need to be productive at the time. The bigger issue, however, is needing to maintain proficiency with QWERTY so that you can continue to use regular keyboards. Other minor annoyances include keyboard shortcuts not always translating well (e.g. copy-paste, HJKL navigation, etc.). More recently, I've run into some issues such as YubiKeys not working properly.
YubiKeys send hardware keypresses; however, if you use a software-based solution to changes keyboard layouts, your YubiKey will end up sending the incorrect keypresses. One (crappy) workaround is to switch layouts every time you use YubiKey, but that's annoying and impractical. Instead, a solution is to reverse-map the keys back to QWERTY for only the Yubikey.
Solution using Karabiner
Karabiner is a great utility for customizing keyboards on Mac OS X. In our particular case, we want to modify the keyboard layout for a specific hardware device.
The first step is pretty simple, just download and install Karabiner.
private.xml custom configuration
Karabiner offers the ability to add your own custom settings by modifying a
private.xml file. Find and open up the
~/Library/Application Support/Karabiner/private.xml configuration file to include the following configuration: Link to Gist.
Loading the configuration in Karabiner
Open the Karabiner preferences, hit "ReloadXML", and then enable the mapping for your keyboard layout:
Note: that this was originally written when Karabiner was called KeyRemap4MacBook, and there was no option for switching to Dvorak for all devices except YubiKeys.
Tips for finding other device vendor and product IDs
If you want to do something similar for other products or devices, but don't know the vendor and product IDs, you can use
system_profiler. Here's an example for finding the Yubikey IDs:
$ system_profiler SPUSBDataType | grep -A3 -i yubikey Yubico Yubikey II: Product ID: 0x0010 Vendor ID: 0x1050
Similarly, you can find all USB devices using the following:
$ system_profiler SPUSBDataType | grep -B2 -A1 -i "product id"
Non-Mac OS X
For X11-based systems, this is actually a bit simpler. You can set a base keyboard layout in your Xorg configuration, and then have a device-specific layout for the YubiKey.