Syntax
Description
Sends a key combination or single key press to the active application (or a specific app if--app is provided). This command simulates pressing and releasing keys in sequence, making it ideal for keyboard shortcuts.
The key is sent at the OS level using native input synthesis, which works globally or can be targeted to a specific application.
Parameters
Key combination to press. See Key Combo Format below for syntax.
Target application name. If provided, focuses the app before pressing the key combo.
Key Combo Format
Single Keys
return, escape, tab, space, delete, backspace, up, down, left, right, home, end, pageup, pagedown
Function keys: f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12
Key Combinations with Modifiers
Multiple Modifiers
Modifier Aliases
cmd,command→ Command/Windows keyctrl,control→ Control keyalt,option→ Alt/Option keyshift→ Shift key
Response
Success Response
Error Response
Examples
Basic Keyboard Shortcuts
Navigation Keys
Application-Targeted Keys
Function Keys
Safety Blocks
The following key combinations are blocked for safety reasons and will return an error:cmd+q— Quit applicationcmd+shift+q— Log outcmd+alt+esc— Force quit dialogctrl+cmd+q— Lock screencmd+shift+delete— Empty trash
close-app command instead.
Error Codes
| Code | Description |
|---|---|
INVALID_ARGS | Invalid key combo format or unknown modifier |
APP_NOT_FOUND | Target app (via --app) is not running |
ACTION_FAILED | OS rejected the key event |
PERM_DENIED | Accessibility permission not granted |
Notes
- Keys are sent to the frontmost application unless
--appis specified - When using
--app, the application is focused before sending the key - The command waits for the key event to be delivered but does not wait for the resulting action to complete
- Special characters in shells may need escaping: use quotes if needed