Skip to content

adamkdean/remap-k120

Repository files navigation

keymap-k120

I have long used Logitech K120 keyboards for non-Mac workstations, but since I moved from using a MacBook everyday to using an iMac Pro every day, I've struggled to find a keyboard that matches the K120. It's not particularly special, but it's comfortable, cheap, easily replacable, and quiet. Unfortunately, it doesn't work very well with MacOS, especially not out of the box.

With help from friends near and far, and all their previous work, I've been able to finally solve my keyboard misery.

Remapped keys

remap-k120 swaps the left and right windows & alt keys to option & command keys, along with swapping F9 onwards. I place this file in /home/adam/bin/remap-k120.

F9 becomes previous track, F10 becomes next track.

F11 becomes volume down, and F12 becomes volume up.

Print Screen becomes play/pause.

Scroll Lock becomes brightness down, and Pause becomes brightness up.

I struggled to find the keycodes for these until I found this fantastic resource.

xpc_set_event_stream_handler

The xpc_set_event_stream_handler consumes events from MacOS. I'm told this is very important.

To compile this, navigate to the directory containing main.m and run clang -framework Foundation main.m -o bin.

I then move this to /usr/local/bin/xpc_set_event_stream_handler.

LaunchDaemon

I place the com.adamkdean.remap-k120.plist file in /Library/LaunchDaemons.

If you use this, be sure to update paths within this file:

<key>ProgramArguments</key>
	<array>
		<string>/usr/local/bin/xpc_set_event_stream_handler</string>
		<string>/Users/adam/bin/remap-k120</string>
		<string>/bin/bash -c "sleep 5"</string>
	</array>
  ...

Resetting

You can easily reset the mappings using the default-mapping file provided by Martin.

Physical alterations

In order to make my life a little better, I used a label maker to adjust the keyboard slightly.

preview

Thanks to

Resources

Keywords

To help people find this, here are some keywords and associated searches:

  • How to use Logitech K120 windows keyboard on Mac?
  • Is Logitech K120 compatible with a Mac?
  • Logitech K120 Mac
  • Can I use Logitech K120 with Mac?
  • Logitech K120
  • Mac, MacOS, OSX