I was trying to remap my Mac's keyboard with Xmodmap, but it was only somewhat successful. The remapping works when I look for the keycodes with the event tester, but when I actually type the keyboard is not remapped. The code I'm using is
nano .Xmodmap

keycode 10 = e
keycode 11 = t
keycode 12 = y
keycode 49 = h
keycode 39 = o
keycode 48 = i
keycode 46 = n
keycode 22 = d
keycode 23 = f
keycode 25 = k
keycode 24 = j
keycode 42 = r
keycode 39 = l
keycode 53 = p
keycode 43 = semicolon
keycode 45 = o
keycode 65 = BackSpace
clear lock

xmodmap .Xmodmap

A similar program (with different keycodes) works on my raspberry pi, so I'm wondering if there's any additional steps needed to be taken on a Mac in order to have the xmodmap keyboard be the one to actually send the keypresses.

  • 1
    I assume you are running X11 on your Mac? In which applications have you tried to use the remapped keys? – nohillside Feb 3 at 19:33
  • I've tried on a bunch of different apps, including chrome, text edit, text wrangler, and terminal. It doesn't work in any of them. The only place where it works is on the event tester. Also, I'm not sure if I'm running X11. It is a MacBook Air 2013 that's software is probably about two years old. If it helps, is there a way that I can check if my computer has X11? – Jack N Feb 3 at 20:38

Xmodmap only works for X11 applications, the ones you've listed for sure are not X11 applications. Most likely you don't use any X11 at all.

To remap keys on macOS see the answer on Karabiner quit working in Sierra. How do I map my menu/application key to be Command? instead.

Another app commonly used to remap MacOS keys is Ukelele.

  • I'm curious about one thing then, why does Xmodmap work on all apps of my raspberry pi including chrome, which it did not work on on my Mac. Also, I currently use Karabiner Elements on my Mac. The reason why I was looking into Xmodmap is because I want to be able to easily share and run my keymap on other Mac's that don't have additional software such as Karabiner Elements installed, similarly to how an AHK script compiled to .exe can run on any Windows machine. Do you know of a way to remap my keyboard that can also be easily sent and run on other computers? – Jack N Feb 3 at 21:51
  • @JackN Ukelele can do this, you share .keyllayout files. – Tom Gewecke Feb 3 at 22:06
  • @JackN Applications on Linux use X11 as the windowing system, applications on macOS don't (unless they are specifically built to use X11 but that's rare nowadays). – nohillside Feb 3 at 22:30
  • @JackN For Windows I think you need to use MSKLC. microsoft.com/en-us/download/details.aspx?id=102134. – Tom Gewecke Feb 3 at 22:33
  • 1
    And even. Linux does not use X11 everywhere now see Wayland – mmmmmm Feb 4 at 10:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .