macOS Keyboard – Using F1, F2 Keys to Control Built-in Mac Features with External USB Keyboard

keyboardmacos

I use a generic external USB keyboard (specifically Amazon Basics Wired Keyboard) with my MacBook Pro. The keyboard doesn't include the fn key present on MacBook's built-in keyboard.

On the external keyboard, I wish for F1, F2 etc. keys to function just like built-in keyboards default configuration, i.e. to control Mac features like adjusting brightness, Mission Control, Launchpad etc. and not work as plain function keys.

How do I configure the external keyboard to do that? I would much prefer for a solution built into macOS rather than relying on a 3rd party app.

I am using a late 2013 15" MacBook Pro running macOS High Sierra 10.13.6.

Best Answer

The fn key isn't a modifier that's sent to the OS, it modifies the scan code that is sent.

To test this out, you can use a built in utility called xev (requires X11) to view the scan codes being sent from your mouse and keyboard. You can also use Karabiner's Event Viewer to to obtain the key press scan codes.

What this means is that the scan code for F1 (130) will be different from the scan code of fnF1 (107). Keep in mind that macOS allows you to "lock" the fn key to a particular behavior (have the function keys act as normal function keys or act as the "special feature keys").

This is different from other modifier keys (like Shift or Option in that both scan codes are sent (i.e. Shift A sends 64 and 8).

As for remapping a keyboard, you can use the built in utility hidutil to remap keys. This answer here can guide you on how to do that.

This is a bit of a workaround for a simple keyboard, and my preference would be to just purchase a cheap keyboard with the fn key functionality built in so everything works out of the box.