Custom Keyboard Layouts on Mac: How to Modify or Create
In this article
Creating or modifying a custom keyboard layout on macOS lets you type in a language, script, or symbol set that the built‑in layouts don’t cover. You can remap keys, add accented characters, or build an entirely new layout for a niche writing system. This guide walks you through the two main methods: using the free third‑party tool Ukelele (the easiest way) and manually editing the XML source files that macOS uses for keyboard layouts. No programming experience is required for the Ukelele method.
What You'll Need
- A Mac running macOS 10.12 or later (the steps work on recent versions like Ventura and Sonoma).
- Ukelele, a free app for creating and editing keyboard layouts. Download it from the official Ukelele website (it’s not on the App Store).
- Basic familiarity with the macOS Finder and System Settings (or System Preferences on older versions).
Step-by-Step
- Install Ukelele. Download the latest Ukelele version from its official site, unzip the file, and drag the app to your Applications folder. Open it once – if macOS warns about an unidentified developer, right‑click the app and choose Open, then confirm.
- Create a new layout. In Ukelele, go to File > New. A window appears showing the standard US keyboard layout. You can also start from an existing layout: File > New from Current Input Source (if you have a different layout active) or File > Open to load a .keylayout file you already have.
- Understand the layout window. The main window shows a grid of keys. Each key has two states: the “normal” character (what you get when you press the key alone) and the “shifted” character (what you get with Shift held). You can also edit the Option and Option+Shift layers by using the pop‑up menu at the top of the window (it usually says “Normal”).
- Edit a key. Double‑click a key to open the Key Editor. In the “Output” field, type the character you want that key to produce. For example, to make the “a” key output “α” when Option is held, select the Option layer, double‑click the “A” key, and type “α”. Click OK to apply.
- Add special characters. If you need a character that isn’t on your keyboard, use the Edit > Insert Character menu. A character viewer opens where you can search for any Unicode character. Double‑click it to insert it into the key’s output.
- Set the layout name. Go to File > Get Info (or press Cmd+I). In the “Name” field, type a name that will appear in the Input Sources list, e.g., “My Custom Layout”. The “ID” field is an internal identifier – you can leave it as is or change it to something unique like “com.mycompany.mylayout”.
- Save the layout. Go to File > Save. Ukelele will ask where to save the file. Choose a location you can remember, like your Desktop. The file will have a .keylayout extension.
- Install the layout. Move the .keylayout file to one of two locations:
- Your user Library: ~/Library/Keyboard Layouts/ (this makes the layout available only to your user account).
- System Library: /Library/Keyboard Layouts/ (requires administrator privileges, makes it available to all users).
- Enable the layout. Open System Settings > Keyboard > Input Sources (on older macOS: System Preferences > Keyboard > Input Sources). Click the “+” button, scroll to the bottom of the list, and you should see your custom layout under “Others” (or “English” if you named it in English). Select it and click Add.
- Switch to your layout. Once added, you can switch to it using the input menu in the menu bar (if you have “Show Input menu in menu bar” enabled) or by pressing the keyboard shortcut you set (usually Control+Space or Cmd+Space). Test your layout in a text editor.
Common Mistakes
- Forgetting to set the Option layer. Many custom layouts rely on the Option key for special characters. If you only edit the Normal layer, you won’t get the extra characters you expected.
- Saving to the wrong folder. If the layout doesn’t appear in Input Sources, it’s likely because the file isn’t in the correct Library/Keyboard Layouts folder. Double‑check the path.
- Not quitting and reopening apps. After installing a layout, some apps may not recognize it until you quit and reopen them. If a layout doesn’t work in an app, try restarting that app.
- Using a non‑standard key ID. If you manually edit the XML and use a wrong key code, the layout may not work. Ukelele avoids this by handling the key codes for you.
Tips
- Start from an existing layout. If you want a layout similar to QWERTY but with a few changes, duplicate the US layout in Ukelele instead of building from scratch.
- Use the “Dead Keys” feature. Ukelele lets you create dead keys – keys that don’t produce a character until you press the next key. This is useful for accents (e.g., pressing ´ then e gives é). To create a dead key, right‑click a key and choose “Dead Key”.
- Test your layout as you go. Ukelele has a built‑in keyboard viewer (Window > Show Keyboard Viewer) that shows what each key produces on the current layer. Use it to check your work before installing.
- Back up your .keylayout file. If you ever reinstall macOS or switch Macs, you’ll need to reinstall the layout. Keep a copy in your iCloud Drive or a USB stick.
Troubleshooting
The layout doesn’t appear in Input Sources. First, verify the file is in the correct folder. Open Finder, press Cmd+Shift+G, and type ~/Library/Keyboard Layouts/. If the file is there, restart your Mac (or at least log out and back in). If it still doesn’t appear, try moving it to /Library/Keyboard Layouts/ (you’ll need admin rights).
The layout appears but doesn’t work. Make sure you’ve selected the layout from the input menu or keyboard shortcut. Also, check that you’re editing the correct layer in Ukelele – if you only defined characters on the Option layer, pressing normal keys will still type the default characters.
Characters are wrong or missing. Open the layout in Ukelele and double‑check each key. A common issue is accidentally setting a key to “No Output” – right‑click the key and choose “Set Output” to fix it.
Ukelele won’t open. If you see a security warning, right‑click the app and select Open, then confirm. If it still won’t open, go to System Settings > Privacy & Security and look for a message about Ukelele being blocked – click “Open Anyway”.
Frequently Asked Questions
Can I modify the built‑in Apple keyboard layouts? No, Apple’s layouts are locked. You can only create new ones or edit third‑party layouts. However, you can duplicate a built‑in layout’s behavior by creating a new layout in Ukelele and copying the key assignments.
Will my custom layout work in all apps? Yes, as long as the app uses standard macOS text input. Some games or specialized software may bypass the system keyboard and use their own input handling, so the layout might not work there.
Can I share my layout with others? Yes, the .keylayout file is portable. Send it to someone else, and they can install it by placing it in their Keyboard Layouts folder and enabling it in Input Sources.
Do I need to be a programmer to create a layout? No. Ukelele provides a graphical interface where you click keys and type characters. Manual XML editing is possible but not necessary for most users.
How do I remove a custom layout? Delete the .keylayout file from the Keyboard Layouts folder, then remove it from Input Sources in System Settings. The layout will disappear after you log out or restart.
Can I create a layout for a language that uses right‑to‑left script? Yes, but you may need to adjust the layout’s direction in the Info window (set “Direction” to “Right to Left”). You may also need to enable the appropriate language in System Settings > Keyboard > Text Input.