Gestures and keys, your way, on Mac. Turn trackpad gestures into keystrokes and commands, and remap keys, per app or per site. Three fingers up, and it presses Return.
One small background app, one JSON file, no account, no subscription. The code is free software under the MIT license.
Run it · Settings · Configure · Extend it · License
swipekey-film-web.mp4
I wanted a three-finger swipe up to press Return. macOS can't map a gesture to a key, and the tool that can, BetterTouchTool, is paid and closed for what is one line of configuration. The open-source options I found were abandoned or did something else. So swipekey does that one thing, and is built so the next gesture or action is a small addition, not a rewrite.
trackpad ─frames─▶ recognizers ─gesture─▶ engine ─▶ actions
(MultitouchSupport) (your config)
swipekey reads raw touches from Apple's MultitouchSupport framework, the same source the system gestures use. A recognizer turns them into gestures (for now, swipes with any number of fingers), and the engine runs the actions you bound to them: a keystroke with modifiers, or a shell command. It needs Accessibility permission to post keystrokes, and nothing else: no network, no telemetry.
Real hands are messy, so recognition allows for how swipes actually happen. The rules were tuned on 169 real swipes, and recognize 168 of them (148 before):
- Fingers land one after another. A 3-finger swipe that starts on 2 fingers never fires the 2-finger binding.
- A 2-finger swipe isn't a scroll. Both are the same movement, so a 2-finger swipe fires when the fingers lift, and only if it was quick and short with both fingers landing together. Scrolling a page sideways, slower and with one finger down first, fires nothing.
- Only gestures you bound count. A gesture with no binding never blocks the one you meant.
- Fingers lift early. With 3+ fingers, a finger leaving before the others doesn't erase the movement.
- Quick flicks count. A fast 3+ finger swipe fires at half the distance.
- Hands drift. The direction is judged in real millimetres: a 3-finger swipe right that heads down a little is still a swipe right (2-finger swipes must be straighter, so a diagonal scroll stays a scroll).
- A resting thumb is ignored. A finger left still on the pad doesn't turn a 3-finger swipe into a 4-finger one.
Each finger must also move the swipe's way, so a pinch or a turn isn't read as a swipe. A 3+ finger swipe that came close but didn't fire writes a line to the log, e.g. near miss: 3-finger swipe up: 0.042 of 0.050 (too short).
make installSwift 5.9 or later (Xcode or the Command Line Tools) on macOS 13 or later. This builds ~/Applications/Swipekey.app, writes a default config and registers a LaunchAgent, so swipekey starts by itself every time you log in and restarts if it crashes.
Then, once:
- Free the gesture. System Settings → Trackpad → More Gestures: move Mission Control (or any gesture on the same fingers and direction) to four fingers, or turn it off.
- Allow it.
make permissionsopens System Settings → Privacy & Security → Accessibility and shows the app in Finder: dragSwipekey.appinto the list. make restart, and swipe.
Swipekey puts a small trackpad icon in the menu bar. From it you can pause and resume the gestures, see the last gesture it recognized and your bindings, open the settings window (⌘,), edit and reload the config, open the log, and quit. The icon dims while paused and turns into a warning sign if swipekey can't send keystrokes. Quit stops it until your next login; after a crash it restarts by itself.
| Command | What it does |
|---|---|
make restart |
Reload after editing the config or granting permission |
make logs |
Follow the log (~/Library/Logs/swipekey.log) |
make test |
Unit tests, no trackpad needed |
make uninstall |
Remove the app and the LaunchAgent, keep the config |
swipekey --debug prints every gesture that fires. swipekey --record <dir> guides you through a few gestures and saves their raw touches as traces for the tests (pause swipekey first).
Everything in the config can be changed here without touching the JSON, and every change applies as soon as you save.
Add or edit a binding in three steps: do the gesture on your trackpad (or pick it by hand), press the shortcut you want, review. System shortcuts like ⌘Space are recorded instead of opening Spotlight, and a gesture already in use, or taken by macOS, is flagged before you save.
Teach a gesture the way you do it, like setting up Touch ID: in a binding's review, Teach… asks for the gesture five times, fills a ring as each one counts (or says why not: wrong number of fingers, another direction, too short), then proposes how far that gesture needs to go, from the shortest of your five. Three-finger gestures only ever get easier this way, two-finger ones only stricter, so scrolling never turns into a swipe. Saved as the binding's "threshold"; Reset goes back to the global value.
Remap keys in the Keys tab: press the key (or choose Pressed twice for a double tap), press what it should become, review. A remap can work everywhere, in one app or on one website, and the most specific one wins. It applies as soon as you save, and two remaps on the same key in the same place are refused.
Keep shortcuts quiet in some places in the Exclusions tab: pick an app or type a website, for all shortcuts or only some of them. A key excluded this way types right away, with no double-tap delay.
Tune the sensitivity with your real fingers: they show up live in the test area, a bar fills toward the threshold, and it tells you whether the swipe fired or how much it fell short. Nothing runs while you test.
~/.config/swipekey/config.json, then Reload config in the menu (or make restart):
{
"swipeThreshold": 0.12,
"bindings": [
{ "gesture": { "type": "swipe", "fingers": 3, "direction": "up" },
"action": { "type": "key", "key": "return" } },
{ "gesture": { "type": "swipe", "fingers": 3, "direction": "up" },
"holding": ["cmd"],
"action": { "type": "key", "key": "return", "modifiers": ["shift"] } },
{ "gesture": { "type": "swipe", "fingers": 3, "direction": "down" },
"action": { "type": "shell", "command": "open -a Terminal" } }
]
}| Field | Values |
|---|---|
gesture |
swipe with fingers (2 and up) and direction (up, down, left, right), or pinch with fingers (2 and up) and direction (in toward the centre, out apart) |
holding |
optional: modifier keys you hold on the keyboard during the gesture (cmd, shift, option, control). The binding fires only with exactly those held, so a plain swipe and a ⌘ + swipe can do different things |
threshold |
optional, per binding: how far this gesture must go (same units as swipeThreshold / pinchThreshold), usually set with Teach… in Settings. When missing, the global value is used |
action |
key with key and optional modifiers (cmd, shift, option, control, fn), or shell with command |
key |
a–z, 0–9, punctuation, return, enter, tab, space, delete, escape, arrows, home, end, pageup, pagedown, f1–f12, or a numeric key code. Characters follow your keyboard layout: z is the key that types z, on QWERTY, AZERTY, QWERTZ or Dvorak |
swipeThreshold |
how far the fingers travel before it fires, as a fraction of the trackpad (default 0.12) |
pinchThreshold |
how much the fingers close or spread before a pinch fires, as a fraction of the trackpad (default 0.05) |
blockScrollWithFingers |
swallow scrolling while this many fingers (or more) touch the trackpad, so a swipe doesn't also scroll the window underneath (default 3, 0 turns it off) |
menuBarIcon |
show the menu bar icon (default true, also in the settings window). Set it back to true and make restart if you hid it and want it back |
dockIcon |
show an icon in the Dock; a click on it opens the settings, and Quit in the Dock only removes the icon: Swipekey stays in the menu bar, and the icon comes back when you open the settings or log in again (default false, also in the settings window) |
editor |
app that Edit config… opens the file with, e.g. "Cursor" or "Visual Studio Code" (default: your default app for JSON). Also set from the menu's Open config with |
remaps |
key events to rewrite: from (key, optional exact modifiers, optional app name or bundle id of the sender, optional taps: 2 for a double tap, optional inApp: only while this app is in front, or url: only on this website, with the same patterns as exclusions) → to (key, modifiers). Rewritten in place before any app sees them; no cost when empty. See the recipes below |
exclusions |
where shortcuts stay quiet: app (name or bundle id of the app in front) or url (see below), with optional only: the shortcuts concerned, named as in the settings window (@@, shift+cmd+a, 3-finger swipe up). Without only, all of them. A remap limited to an app or a website still works there. No cost when empty |
"url" patterns: github.com is the whole site, github.com/a that page and what's under it, and * is any text (github.com/*/pull/*, *.google.com). The scheme, www., the query and the fragment don't count. The address is read with AppleScript from Chrome, Brave, Edge, Arc, Vivaldi and Safari, not Firefox, twice a second while one of them is in front and an exclusion names a URL. macOS asks once per browser. So a shortcut can follow the previous page for up to half a second after you change tabs. The address stays on your Mac.
Each recipe is one or two entries to paste into bindings. Some recipes use the same gesture: pick one per gesture, since a gesture bound twice runs both actions. Before using one, check that macOS doesn't already use that gesture (System Settings → Trackpad → More Gestures).
Send messages, confirm dialogs or run terminal commands without reaching for the keyboard.
{ "gesture": { "type": "swipe", "fingers": 3, "direction": "up" },
"action": { "type": "key", "key": "return" } }Previous and next tab in Safari, Chrome, Arc, Firefox and most editors. ⌃⇧Tab and ⌃Tab work on every keyboard layout, unlike ⌘⇧[, which has no single key on AZERTY.
{ "gesture": { "type": "swipe", "fingers": 4, "direction": "left" },
"action": { "type": "key", "key": "tab", "modifiers": ["control", "shift"] } },
{ "gesture": { "type": "swipe", "fingers": 4, "direction": "right" },
"action": { "type": "key", "key": "tab", "modifiers": ["control"] } }Hold a key on the keyboard while you swipe to get a second action on the same gesture. Here a plain swipe up sends Return, and ⌘ + swipe up sends ⇧Return (a new line in Slack, Messages or ChatGPT instead of sending).
{ "gesture": { "type": "swipe", "fingers": 3, "direction": "up" },
"action": { "type": "key", "key": "return" } },
{ "gesture": { "type": "swipe", "fingers": 3, "direction": "up" },
"holding": ["cmd"],
"action": { "type": "key", "key": "return", "modifiers": ["shift"] } }Pinch two fingers toward the centre to press ⌘@. @ follows your layout, like any character key.
{ "gesture": { "type": "pinch", "fingers": 2, "direction": "in" },
"action": { "type": "key", "key": "@", "modifiers": ["cmd"] } }macOS still zooms on a two-finger pinch in apps that support it: turn off Zoom in or out in System Settings → Trackpad → Scroll & Zoom if that gets in the way.
{ "gesture": { "type": "swipe", "fingers": 4, "direction": "down" },
"action": { "type": "key", "key": "w", "modifiers": ["cmd"] } }{ "gesture": { "type": "swipe", "fingers": 3, "direction": "left" },
"action": { "type": "key", "key": "z", "modifiers": ["cmd"] } },
{ "gesture": { "type": "swipe", "fingers": 3, "direction": "right" },
"action": { "type": "key", "key": "z", "modifiers": ["cmd", "shift"] } }{ "gesture": { "type": "swipe", "fingers": 3, "direction": "down" },
"action": { "type": "key", "key": "escape" } }Opens the macOS selection screenshot (⌘⇧4).
{ "gesture": { "type": "swipe", "fingers": 5, "direction": "up" },
"action": { "type": "key", "key": "4", "modifiers": ["cmd", "shift"] } }Apple Music; replace Music with Spotify for Spotify.
{ "gesture": { "type": "swipe", "fingers": 5, "direction": "down" },
"action": { "type": "shell", "command": "osascript -e 'tell application \"Music\" to playpause'" } }{ "gesture": { "type": "swipe", "fingers": 5, "direction": "right" },
"action": { "type": "shell", "command": "osascript -e 'set volume output volume ((output volume of (get volume settings)) + 10)'" } },
{ "gesture": { "type": "swipe", "fingers": 5, "direction": "left" },
"action": { "type": "shell", "command": "osascript -e 'set volume output volume ((output volume of (get volume settings)) - 10)'" } }{ "gesture": { "type": "swipe", "fingers": 4, "direction": "up" },
"action": { "type": "shell", "command": "open -a Terminal" } }open https://github.com works the same way for a URL.
Anything you built in the Shortcuts app: toggle Focus, start a timer, post to a webhook.
{ "gesture": { "type": "swipe", "fingers": 2, "direction": "up" },
"action": { "type": "shell", "command": "shortcuts run \"My Shortcut\"" } }Two-finger swipes also scroll the page, so keep them for actions where that doesn't matter.
Turns the display off; it locks if Require password is set to Immediately in Lock Screen settings.
{ "gesture": { "type": "swipe", "fingers": 5, "direction": "down" },
"action": { "type": "shell", "command": "pmset displaysleepnow" } }Some mouse utilities send a shortcut's key without its modifiers on non-US keyboards: Logi Options+ sends a plain Space for ⌃⌥Space on French AZERTY, so dictation apps like Wispr Flow never see the shortcut. Map that button to Space in the mouse app, then put the modifiers back, only for events that app sends (your real space bar is untouched):
"remaps": [
{ "from": { "key": "space", "app": "Logi Options+" },
"to": { "key": "space", "modifiers": ["control", "option"] } }
]Two quick presses of @ send Return, so you can dictate (⌘@ in Wispr Flow) and send with the left hand only:
"remaps": [
{ "from": { "key": "@", "taps": 2 }, "to": { "key": "return" } }
]A single @ still types @, a quarter of a second late (only then is it known not to be a double tap), or right away when you type another key. With modifiers (⌘@) or held down, the key works as usual. Typing @@ is no longer possible.
"remaps": [
{ "from": { "key": "@", "taps": 2, "url": "github.com/*/pull/*" }, "to": { "key": "return", "modifiers": ["cmd"] } }
]Off that website the key stays itself, or follows your general remap of it if you have one.
These recipes can also be made in Settings → Keys. remaps sits next to bindings at the top level of the config.
- A new action (open a URL, run a Shortcut): a case in
ActionSpecand a type that conforms toAction, inActions.swift. - A new gesture (taps, pinches): a case in
Gesture, aGestureRecognizerinRecognizers.swift, and one line inEngine.init. Recognizers are plain classes fed with touch frames, so they are tested without a trackpad.
Sources/CMultitouch/: the C bridge that loadsMultitouchSupportand forwards touch frames.Sources/SwipeKeyCore/: gestures, recognizers, actions, config and the engine.Sources/swipekey/: the command-line entry point.support/: the app'sInfo.plistand the LaunchAgent template.Tests/: unit tests for recognition and config.
MultitouchSupportis private Apple API. It has been stable for over a decade and many tools rely on it, but a macOS update could break it.make installsigns the app with your Apple Development or Developer ID certificate when your keychain has one, and macOS then keeps the Accessibility grant across updates. Without a certificate the app is signed ad hoc, and macOS ties the grant to that exact build: after each update, turn Swipekey off and on in the Accessibility list, thenmake restart. Either way,make installonly replaces the app when the code changed.- macOS still sees the gesture. If a system gesture uses the same fingers and direction, both fire. With those gestures off, macOS treats a three-finger swipe as plain scrolling: swipekey swallows that scrolling (see
blockScrollWithFingers). - An excluded gesture runs nothing, but multi-finger scrolling is still swallowed there (see
blockScrollWithFingers).
Copyright (C) 2026 Snouzy and the swipekey contributors. MIT.

