One option would be to save this as private.xml in KeyRemap4MacBook.
<autogen>--KeyToKey-- KeyCode::Y, KeyCode::Z</autogen>
<autogen>--KeyToKey-- KeyCode::Z, KeyCode::Y</autogen>
You could also use Ukelele to make a new keyboard layout.
- Select the U.S. layout and choose File > New Based on Current Input Source
- Change the keys
- Save as a bundle to
/Library/Keyboard Layouts/. Keyboard layouts in the user library aren't selected by default in password dialogs. The popovers shown when holding keys don't work with normal keylayout files.
- Log out and back in
- Enable the input source in System Preferences
To apply changes to a keylayout file you have to log out and back in after for example running
touch /Library/Keyboard Layouts/.
If you run Setup Assistant again (
sudo rm /var/db/.AppleSetupDone; sudo /System/Library/CoreServices/Setup\ Assistant.app/Contents/MacOS/Setup Assistant), the keyboard layout you select will be used by default on the login window and guest accounts.