Remap keys in OS X
Asked Answered
L

4

6

Specifically I'm attempting to map my MacBook's fn key to left mouse click.

Back in the old days when I was using Windows, I came across a wonderful little utility that let me map anything to anything: http://www.autohotkey.com/

You create a little text file, e.g.

^!s::                             ; CTRL + ALT + s
Send Sincerely,{enter}John Smith  ; sends keystrokes to active window
return

Creating a simple text file was infinitely better than any GUI based remapper.

  • I can look through it and see everything that is going on at a glance
  • I can customise every last detail
  • I can save / retrieve / post / share my scripts

Really, it's the one thing I really miss about Windows.

So my question is: How do I go about doing this in OS X? Every Google search leads to https://pqrs.org/macosx/keyremap4macbook/ and I dislike this package: it has an insanely cluttered GUI.

I would be very happy if I could do it in a shell script, or even compile code.

Lorenelorens answered 16/11, 2013 at 14:56 Comment(0)
T
3

HotKeys on OS X

Even though AHK is seemingly absent on Mac, the functionality that AHK provides on Windows can likely be achieved in OS X. It could be a matter of coding your own solution, modifying something that's open-source, or using a combination of applications that will work together. I haven't tried all of the following, but might as well mention them as they might be worth checking out:

Open Source

IronAHK - .NET rewrite of AHK ported to OS X

*the original project might be dead

CliClick - command-line application that will emulate mouse clicks

Commercial

TextExpander - scriptable text completion / hotkey / macro app (supports AppleScript, Shell scripts)

Typinator - similar to TextExpander, although some features vary.

KeyMo - mostly for mapping keys exclusively to your mouse.

FastScripts - maps hotkeys/user-definable keyboard shortcuts to AppleScripts

*I use Text Expander and FastScripts together and can't live without them.

Rolling Your Own

It's fairly easy to create something with an AppleScript, or a shell script for just about anything imaginable in OS X. For example, I've seen CliClick used along with a custom AppleScript to achieve a certain functionality that it might not provide otherwise. To find an AHK replacement on Mac it'll probably be through trial and error, patience, and ultimately what ends up working best for you.

Tarsometatarsus answered 20/1, 2014 at 22:34 Comment(0)
F
1

It is possible with a program called ControllerMate, instructions here. It is, however, a commercial software. I'm also interested in finding a free alternative.

Foreordain answered 30/12, 2013 at 15:42 Comment(0)
M
1

Sikuli project looks promising. Not sure about your particular problem (e.g. Fn key remapping), but it's definitely a crossplatform alternative to AHK.

Milford answered 20/1, 2014 at 11:24 Comment(0)
O
0

Another Open Source solution to this problem not mentioned in l'L'l's answer is Karabiner; I have been looking for a way to remap the key to the left of 1 to Esc for a while, and this worked perfectly. It even resolved an issue I was having where swapping Cmd and Alt using the built in OSX key remapping was breaking terminal Alt shortcuts! Highly recommend it.

Outport answered 19/8, 2019 at 12:35 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.