Press and hold for 1.5 seconds to put your Mac to sleep. Continue holding to force your Mac to turn off. Option–Command–Power button. or Option–Command–Media Eject: Put your Mac to sleep. Control–Shift–Power button. or Control–Shift–Media Eject: Put your displays to sleep. Audacity beat maker. The Command and Option Key Swap Besides Windows and Mac keyboards having slightly different names, they also swap the positions of two often-used modifier keys: the Command and Option keys. If you're a long-time Mac user transitioning to a Windows keyboard, the Windows key, which is equivalent to the Mac's Command key, may occupy the physical.
To use a keyboard shortcut, press and hold one or more modifier keys and then press the last key of the shortcut. For example, to use Command-C (copy), press and hold the Command key, then the C key, then release both keys. Mac menus and keyboards often use symbols for certain keys, including modifier keys:
On keyboards made for Windows PCs, use the Alt key instead of Option, and the Windows logo key instead of Command.
- To do this, use Method 1 to access Startup Manager. Once you are there, press Option-Shift-Command-Period. You should now be able to see the USB drive. This is not exactly a problem as much as a feature. If the USB contains Option ROM firmware, you will need to press those keys everytime to boot from your pen drive.
- To fix this, just press Option-Shift-Command-Period at the Startup Manager window. Do this each time you want to start from the external device or from a startup disk connected to it. If you don't want to do this and you're using an older Mac model (2015 and before), you can can disable this security feature and allow your Mac to load Option ROM firmware.
Some keys on some Apple keyboards have special symbols and functions, such as for display brightness , keyboard brightness , Mission Control, and more. If these functions aren't available on your keyboard, you might be able to reproduce some of them by creating your own keyboard shortcuts. To use these keys as F1, F2, F3, or other standard function keys, combine them with the Fn key.
Cut, copy, paste, and other common shortcuts
- Command-X: Cut the selected item and copy it to the Clipboard.
- Command-C: Copy the selected item to the Clipboard. This also works for files in the Finder.
- Command-V: Paste the contents of the Clipboard into the current document or app. This also works for files in the Finder.
- Command-Z: Undo the previous command. You can then press Shift-Command-Z to Redo, reversing the undo command. In some apps, you can undo and redo multiple commands.
- Command-A: Select All items.
- Command-F: Find items in a document or open a Find window.
- Command-G: Find Again: Find the next occurrence of the item previously found. To find the previous occurrence, press Shift-Command-G.
- Command-H: Hide the windows of the front app. To view the front app but hide all other apps, press Option-Command-H.
- Command-M: Minimize the front window to the Dock. To minimize all windows of the front app, press Option-Command-M.
- Command-O: Open the selected item, or open a dialog to select a file to open.
- Command-P: Print the current document.
- Command-S: Save the current document.
- Command-T: Open a new tab.
- Command-W: Close the front window. To close all windows of the app, press Option-Command-W.
- Option-Command-Esc: Force quit an app.
- Command–Space bar: Show or hide the Spotlight search field. To perform a Spotlight search from a Finder window, press Command–Option–Space bar. (If you use multiple input sources to type in different languages, these shortcuts change input sources instead of showing Spotlight. Learn how to change a conflicting keyboard shortcut.)
- Control–Command–Space bar: Show the Character Viewer, from which you can choose emoji and other symbols.
- Control-Command-F: Use the app in full screen, if supported by the app.
- Space bar: Use Quick Look to preview the selected item.
- Command-Tab: Switch to the next most recently used app among your open apps.
- Shift-Command-5: In macOS Mojave or later, take a screenshot or make a screen recording. Or use Shift-Command-3 or Shift-Command-4 for screenshots. Learn more about screenshots.
- Shift-Command-N: Create a new folder in the Finder.
- Command-Comma (,): Open preferences for the front app.
Sleep, log out, and shut down shortcuts
You might need to press and hold some of these shortcuts for slightly longer than other shortcuts. This helps you to avoid using them unintentionally.
- Power button: Press to turn on your Mac or wake it from sleep. Press and hold for 1.5 seconds to put your Mac to sleep.* Continue holding to force your Mac to turn off.
- Option–Command–Power button* or Option–Command–Media Eject : Put your Mac to sleep.
- Control–Shift–Power button* or Control–Shift–Media Eject : Put your displays to sleep.
- Control–Power button* or Control–Media Eject : Display a dialog asking whether you want to restart, sleep, or shut down.
- Control–Command–Power button:* Force your Mac to restart, without prompting to save any open and unsaved documents.
- Control–Command–Media Eject : Quit all apps, then restart your Mac. If any open documents have unsaved changes, you will be asked whether you want to save them.
- Control–Option–Command–Power button* or Control–Option–Command–Media Eject : Quit all apps, then shut down your Mac. If any open documents have unsaved changes, you will be asked whether you want to save them.
- Control-Command-Q: Immediately lock your screen.
- Shift-Command-Q: Log out of your macOS user account. You will be asked to confirm. To log out immediately without confirming, press Option-Shift-Command-Q.
* Does not apply to the Touch ID sensor.
Finder and system shortcuts
- Command-D: Duplicate the selected files.
- Command-E: Eject the selected disk or volume.
- Command-F: Start a Spotlight search in the Finder window.
- Command-I: Show the Get Info window for a selected file.
- Command-R: (1) When an alias is selected in the Finder: show the original file for the selected alias. (2) In some apps, such as Calendar or Safari, refresh or reload the page. (3) In Software Update preferences, check for software updates again.
- Shift-Command-C: Open the Computer window.
- Shift-Command-D: Open the desktop folder.
- Shift-Command-F: Open the Recents window, showing all of the files you viewed or changed recently.
- Shift-Command-G: Open a Go to Folder window.
- Shift-Command-H: Open the Home folder of the current macOS user account.
- Shift-Command-I: Open iCloud Drive.
- Shift-Command-K: Open the Network window.
- Option-Command-L: Open the Downloads folder.
- Shift-Command-N: Create a new folder.
- Shift-Command-O: Open the Documents folder.
- Shift-Command-P: Show or hide the Preview pane in Finder windows.
- Shift-Command-R: Open the AirDrop window.
- Shift-Command-T: Show or hide the tab bar in Finder windows.
- Control-Shift-Command-T: Add selected Finder item to the Dock (OS X Mavericks or later)
- Shift-Command-U: Open the Utilities folder.
- Option-Command-D: Show or hide the Dock.
- Control-Command-T: Add the selected item to the sidebar (OS X Mavericks or later).
- Option-Command-P: Hide or show the path bar in Finder windows.
- Option-Command-S: Hide or show the Sidebar in Finder windows.
- Command–Slash (/): Hide or show the status bar in Finder windows.
- Command-J: Show View Options.
- Command-K: Open the Connect to Server window.
- Control-Command-A: Make an alias of the selected item.
- Command-N: Open a new Finder window.
- Option-Command-N: Create a new Smart Folder.
- Command-T: Show or hide the tab bar when a single tab is open in the current Finder window.
- Option-Command-T: Show or hide the toolbar when a single tab is open in the current Finder window.
- Option-Command-V: Move the files in the Clipboard from their original location to the current location.
- Command-Y: Use Quick Look to preview the selected files.
- Option-Command-Y: View a Quick Look slideshow of the selected files.
- Command-1: View the items in the Finder window as icons.
- Command-2: View the items in a Finder window as a list.
- Command-3: View the items in a Finder window in columns.
- Command-4: View the items in a Finder window in a gallery.
- Command–Left Bracket ([): Go to the previous folder.
- Command–Right Bracket (]): Go to the next folder.
- Command–Up Arrow: Open the folder that contains the current folder.
- Command–Control–Up Arrow: Open the folder that contains the current folder in a new window.
- Command–Down Arrow: Open the selected item.
- Right Arrow: Open the selected folder. This works only when in list view.
- Left Arrow: Close the selected folder. This works only when in list view.
- Command-Delete: Move the selected item to the Trash.
- Shift-Command-Delete: Empty the Trash.
- Option-Shift-Command-Delete: Empty the Trash without confirmation dialog.
- Command–Brightness Down: Turn video mirroring on or off when your Mac is connected to more than one display.
- Option–Brightness Up: Open Displays preferences. This works with either Brightness key.
- Control–Brightness Up or Control–Brightness Down: Change the brightness of your external display, if supported by your display.
- Option–Shift–Brightness Up or Option–Shift–Brightness Down: Adjust the display brightness in smaller steps. Add the Control key to this shortcut to make the adjustment on your external display, if supported by your display.
- Option–Mission Control: Open Mission Control preferences.
- Command–Mission Control: Show the desktop.
- Control–Down Arrow: Show all windows of the front app.
- Option–Volume Up: Open Sound preferences. This works with any of the volume keys.
- Option–Shift–Volume Up or Option–Shift–Volume Down: Adjust the sound volume in smaller steps.
- Option–Keyboard Brightness Up: Open Keyboard preferences. This works with either Keyboard Brightness key.
- Option–Shift–Keyboard Brightness Up or Option–Shift–Keyboard Brightness Down: Adjust the keyboard brightness in smaller steps.
- Option key while double-clicking: Open the item in a separate window, then close the original window.
- Command key while double-clicking: Open a folder in a separate tab or window.
- Command key while dragging to another volume: Move the dragged item to the other volume, instead of copying it.
- Option key while dragging: Copy the dragged item. The pointer changes while you drag the item.
- Option-Command while dragging: Make an alias of the dragged item. The pointer changes while you drag the item.
- Option-click a disclosure triangle: Open all folders within the selected folder. This works only when in list view.
- Command-click a window title: See the folders that contain the current folder.
- Learn how to use Command or Shift to select multiple items in the Finder.
- Click the Go menu in the Finder menu bar to see shortcuts for opening many commonly used folders, such as Applications, Documents, Downloads, Utilities, and iCloud Drive.
Document shortcuts
The behavior of these shortcuts may vary with the app you're using.
- Command-B: Boldface the selected text, or turn boldfacing on or off.
- Command-I: Italicize the selected text, or turn italics on or off.
- Command-K: Add a web link.
- Command-U: Underline the selected text, or turn underlining on or off.
- Command-T: Show or hide the Fonts window.
- Command-D: Select the Desktop folder from within an Open dialog or Save dialog.
- Control-Command-D: Show or hide the definition of the selected word.
- Shift-Command-Colon (:): Display the Spelling and Grammar window.
- Command-Semicolon (;): Find misspelled words in the document.
- Option-Delete: Delete the word to the left of the insertion point.
- Control-H: Delete the character to the left of the insertion point. Or use Delete.
- Control-D: Delete the character to the right of the insertion point. Or use Fn-Delete.
- Fn-Delete: Forward delete on keyboards that don't have a Forward Delete key. Or use Control-D.
- Control-K: Delete the text between the insertion point and the end of the line or paragraph.
- Fn–Up Arrow: Page Up: Scroll up one page.
- Fn–Down Arrow: Page Down: Scroll down one page.
- Fn–Left Arrow: Home: Scroll to the beginning of a document.
- Fn–Right Arrow: End: Scroll to the end of a document.
- Command–Up Arrow: Move the insertion point to the beginning of the document.
- Command–Down Arrow: Move the insertion point to the end of the document.
- Command–Left Arrow: Move the insertion point to the beginning of the current line.
- Command–Right Arrow: Move the insertion point to the end of the current line.
- Option–Left Arrow: Move the insertion point to the beginning of the previous word.
- Option–Right Arrow: Move the insertion point to the end of the next word.
- Shift–Command–Up Arrow: Select the text between the insertion point and the beginning of the document.
- Shift–Command–Down Arrow: Select the text between the insertion point and the end of the document.
- Shift–Command–Left Arrow: Select the text between the insertion point and the beginning of the current line.
- Shift–Command–Right Arrow: Select the text between the insertion point and the end of the current line.
- Shift–Up Arrow: Extend text selection to the nearest character at the same horizontal location on the line above.
- Shift–Down Arrow: Extend text selection to the nearest character at the same horizontal location on the line below.
- Shift–Left Arrow: Extend text selection one character to the left.
- Shift–Right Arrow: Extend text selection one character to the right.
- Option–Shift–Up Arrow: Extend text selection to the beginning of the current paragraph, then to the beginning of the following paragraph if pressed again.
- Option–Shift–Down Arrow: Extend text selection to the end of the current paragraph, then to the end of the following paragraph if pressed again.
- Option–Shift–Left Arrow: Extend text selection to the beginning of the current word, then to the beginning of the following word if pressed again.
- Option–Shift–Right Arrow: Extend text selection to the end of the current word, then to the end of the following word if pressed again.
- Control-A: Move to the beginning of the line or paragraph.
- Control-E: Move to the end of a line or paragraph.
- Control-F: Move one character forward.
- Control-B: Move one character backward.
- Control-L: Center the cursor or selection in the visible area.
- Control-P: Move up one line.
- Control-N: Move down one line.
- Control-O: Insert a new line after the insertion point.
- Control-T: Swap the character behind the insertion point with the character in front of the insertion point.
- Command–Left Curly Bracket ({): Left align.
- Command–Right Curly Bracket (}): Right align.
- Shift–Command–Vertical bar (|): Center align.
- Option-Command-F: Go to the search field.
- Option-Command-T: Show or hide a toolbar in the app.
- Option-Command-C: Copy Style: Copy the formatting settings of the selected item to the Clipboard.
- Option-Command-V: Paste Style: Apply the copied style to the selected item.
- Option-Shift-Command-V: Paste and Match Style: Apply the style of the surrounding content to the item pasted within that content.
- Option-Command-I: Show or hide the inspector window.
- Shift-Command-P: Page setup: Display a window for selecting document settings.
- Shift-Command-S: Display the Save As dialog, or duplicate the current document.
- Shift–Command–Minus sign (-): Decrease the size of the selected item.
- Shift–Command–Plus sign (+): Increase the size of the selected item. Command–Equal sign (=) performs the same function.
- Shift–Command–Question mark (?): Open the Help menu.
Other shortcuts
For more shortcuts, check the shortcut abbreviations shown in the menus of your apps. Every app can have its own shortcuts, and shortcuts that work in one app might not work in another.
- Apple Music shortcuts: Choose Help > Keyboard shortcuts from the menu bar in the Music app.
- Other shortcuts: Choose Apple menu > System Preferences, click Keyboard, then click Shortcuts.
Learn more
- Create your own shortcuts and resolve conflicts between shortcuts
- Change the behavior of the function keys or modifier keys
- By Christopher Kielty, last updated May 10, 2018
All of the key codes. All of them. Ever. Maybe. I tested this out on a MacBook Air and also a MacBook Pro. If I missed something, please let me know.
Key code 49 in this example triggers the space bar.
You may also want to check out this short introduction to keyboard automation in macOS (with AppleScript). Snap and share pro.
The play/pause function keys don't trigger correctly using key codes, but there's a workaround for this, which I'll go over.
Keyboard brightness keysdon't work with key codes. I don't know how to make them work. Yet.. Yet.
Oh, and also caps lock. It doesn't look like key code 57 enables caps lock. I am looking into this.
Return and enter
The enter key on most Macs is actually the return key (key code 36). The key code for enter is 76. The enter key is what you might see on a full size keyboard on the numpad side. On the more common, non-full-size Mac keyboards, enter can still be accomplished by hitting fn + enter. This is why the enter key says return and enter on it.
Most applications don't really care about the difference between return and enter. In pretty much every text editor both enter and return will result in the same new line. One example of where these two keys do different things is with iTunes. Interestingly, in iTunes, enter (76) renames the currently selected song while return (36) plays the song from the beginning. This is still true as of iTunes 12 running on OS X 10.10 Yosemite.
Modifier keys
Most of the modifiers have two different key codes. One for the left and one for the right. So instead of just triggering, say, option, you can trigger (right) option specifically. This applies to option, shift, and control. It appears that command has only one key code. I think it is worth noting that the keyboard on the MacBook Air I'm using right now has only one control key on the physical keyboard.
- (Right) control:
key code 62
- (Right) option:
key code 61
- (Right) shift:
key code 60
While this is all fine and dandy, I'm guessing you probably want to use these keys to modify other keys. They are modifier keys, right? Actually, key codes aren't even needed to accomplish this. For example, you could do command + A like this:
Use multiple modifier keys with {.., ..}
. In this example, let's do a 'Paste and Match Style' with option + shift + command + V like this:
Key code 9, in the example above, is the V key. But it would be just as easy to use keystroke, like this:
For numbers, letters, and symbols, using keystroke is probably better. However, there's still key codes if you want 'em.
Remember, when using keystroke, place the characters in quotes. Also, don't forget, keystroke (one word), key code (two words). I accidentally type keycode sometimes.
Option Shift Command Period Definition
Like that
Arrow keys, page up, page down, home and end
Arrow keys are pretty great. And also the page up, page down, home, and end keys. Those are pretty great also. Scripting them is awesome. And this is where key codes are really necessary. You can't write keystroke up arrow. That won't work. You don't need to try that. I've saved you the trouble.
Some nifty arrow key examples. Try these in a text editor to move the cursor around:
Skip ahead one word: tell application 'System Events' to key code 124 using option down
Go back one word: tell application 'System Events' to key code 123 using option down
Skip to the end of the paragraph: tell application 'System Events' to key code 125 using option down
Go back to the beginning of the paragraph: tell application 'System Events' to key code 126 using option down
Skip to the end of the line: tell application 'System Events' to key code 124 using command down
Go back to the beginning of the line: tell application 'System Events' to key code 123 using command down
Esc, space bar, tab, delete, caps lock
All of these work as expected, except for caps lock. It doesn't look like key code 57 does anything. Too bad. That'd be neat.
Keystroke works just fine for triggering the return, space, and tab keys.
keystroke return
keystroke space
keystroke tab
This is the exception to the rule about keystroke and quotes. Putting 'return' in quotation marks would write out return. No quotes and the return key is triggered.
F keys and some of the function keys
Not all of the function keys can be reliably scripted using key codes. See further down for work arounds.
In the diagram above, some of the keys list two key codes. The top number corresponds to the function and the bottom number corresponds to the F key. For example, this would increase screen brightness by one increment, the same as pressing the screen brightness key.
What about F13-F20? Those are scriptable too!
- F13:
key code 105
- F14:
key code 107
- F15:
key code 113
- F16:
key code 106
- F17:
key code 64
- F18:
key code 79
- F19:
key code 80
- F20:
key code 90
Play, pause, fast forward, rewind and volume function keys
I dunno if there's a good way to do this using key codes. You can leapfrog this hurdle by just not using key codes.
- Play:
tell application 'iTunes' to play
- Pause:
tell application 'iTunes' to pause
- Rewind (previous track):
tell application 'iTunes' to previous track
- Fast forward (next track):
tell application 'iTunes' to next track
If you're using something other than iTunes, you can still try the above. Just substitute 'iTunes' with the name of the app. Depending on how scriptable the app is, this may or may not work.
Mute, unmute, set and increment system volume like so:
- Mute:
set volume with output muted
- Unmute:
set volume without output muted
- Set volume to 100%:
set volume output volume 100
- Set volume to 50%:
set volume output volume 50
- Set volume to 1%:
set volume 1
Make your system volume slowly fade out with this nifty little script. Adjust the 'delay 0.2' bit in the middle of the loop to speed up or slow down the fade.
- Basically..
- Set a to current volume
- Repeat until volume is zero
- Set volume decrement to current volume -1%
- Delay 0.2 seconds between each decrement
- Decrement volume by set amount.
Controlling keyboard brightness
I don't know how to control keyboard brightness with Applescript. Yet. Iphone screen simulator.
Letters, numbers and symbols
Shift Command Period
Instead of using key codes, why not just use keystrokes? This works great with all of the letter keys (upper and lower case). Also, the number keys (above the letter keys, not numpad) and all of the symbols you can make with them using shift. Also these keys: ~ `{ [} ]| : ;' '_ -+ =< ,> . and ? /. And also other keys.
Keystroke works like this:
Option Shift Command Periodic
Keystrokes might be super cool, and awesome, and generally pretty great and what have you. But guess what! There's also key codes for these!..:
- ! 1:
key code 18
- @ 2:
key code 19
- # 3:
key code 20
- $ 4:
key code 21
- % 5:
key code 23
- ^ 6:
key code 22
- & 7:
key code 26
- * 8:
key code 28
- ( 9:
key code 25
- ) 0:
key code 29
- ~ `:
key code 50
- { [:
key code 33
- } ]:
key code 30
- | :
key code 42
- : ;:
key code 41
- ' ':
key code 39
- _ -:
key code 27
- + =:
key code 24
- < ,:
key code 43
- > .:
key code 47
- ? /:
key code 44
- N:
key code 45
- M:
key code 46
- Q:
key code 12
- W:
key code 13
- E:
key code 14
- R:
key code 15
- T:
key code 17
- Y:
key code 16
- U:
key code 32
- I:
key code 34
- O:
key code 31
- P:
key code 35
- A:
key code 0
- S:
key code 1
- D:
key code 2
- F:
key code 3
- G:
key code 5
- H:
key code 4
- J:
key code 38
- K:
key code 40
- L:
key code 37
- Z:
key code 6
- X:
key code 7
- C:
key code 8
- V:
key code 9
- B:
key code 11
Numpad key codes
And the numpad. There's even key codes for the numpad. Key codes for everyone!
- Numpad1:
key code 83
- Numpad2:
key code 84
- Numpad3:
key code 85
- Numpad4:
key code 86
- Numpad5:
key code 87
- Numpad6:
key code 88
- Numpad7:
key code 89
- Numpad8:
key code 91
- Numpad9:
key code 92
- Numpad0:
key code 82
- Numpad*:
key code 67
- Numpad/:
key code 75
- Numpad+:
key code 69
- Numpad-:
key code 78
- Numpad=:
key code 81
- Numpad.:
key code 65
- Numpadclear:
key code 71