34

I am looking for a quick way to sleep without closing the lid, or using the mouse.

If it matters, I have Lion version OS and a MacBook Air.

10 Answers 10

30

If others do have a keyboard with an eject key, you can just press Command ⌘+Option ⌥+Eject ⏏.

Other shortcuts:

Control ^+Shift ⇧+Eject ⏏ - Put displays to sleep
Command ⌘+Control ^+Eject ⏏ - Restart
Command ⌘+Control ^+Option ⌥+Eject ⏏ - Shut down

If others like the OP have a MacBook Air or a MacBook Pro with a power key in place of an eject key, substituting the power key for eject should work in Mountain Lion and later versions of OS X, but not in Lion.

Since Mavericks, another option is to just press the power button or power key. It now puts a Mac to sleep instead of showing a dialog with different options.

If you don't have a keyboard with an eject or power key, you can use a private.xml like this with KeyRemap4MacBook:

<?xml version="1.0"?>
<root>
  <item>
    <name>test</name>
    <identifier>test</identifier>
    <autogen>__KeyToKey__ KeyCode::S, VK_CONTROL, VK_OPTION, VK_COMMAND | ModifierFlag::NONE, KeyCode::VK_CONSUMERKEY_EJECT, ModifierFlag::OPTION_L | ModifierFlag::COMMAND_L</autogen>
 </item>
</root>

Or create a workflow like this in Alfred:

3
  • 1
    Yep, this is nice. Keeping it uniform across all Macs :)
    – gentmatt
    Dec 7, 2012 at 14:19
  • 1
    KeyRemap4MacBook was renamed to Karabiner, which has been obsoleted in favor of Karabiner-Elements: karabiner-elements.pqrs.org
    – Carl Walsh
    Sep 9, 2020 at 21:47
  • When I want my display to darken, I do CMD OPT q; this gives me the login screen. Then ESC darkens it. How does this differ from the above solution? Feb 27 at 15:13
24

You can assign any unused key combination (like fnF12) using System Preferences » Keyboard » Keyboard Shortcuts » Application Shortcuts Click the + button, then under Application, leave All Applications, under Menu Title enter Sleep, and under Keyboard Shortcut, press fnF12.

Note: For the step "under Menu Title enter Sleep", the Sleep is according to your language. For example, under Traditional Chinese, you should enter 睡眠.

enter image description here

Another option, if you're more Terminal-inclined:

  • space
  • Type Terminal
  • push Enter
  • Type sudo shutdown -s now
5
  • Thanks for this solution that works on a non-Mac keyboard.
    – Thierry J.
    Mar 9, 2018 at 14:11
  • Woahhh this thing is working, superb. Apr 12, 2019 at 2:02
  • Awesome. Worked for me!
    – Stan
    May 1, 2022 at 19:28
  • 1
    I didn't want to use internal laptop buttons as they don't necessarily exist on an external keyboard. I used command+control+s. It's a similar to the convention to lock the computer: command+control+q. Jun 20, 2022 at 8:38
  • 1
    I'm sure my upvote of this was years ago but I'm back again and appreciating it again. Thanks.
    – Ryan
    Aug 18, 2022 at 18:44
11

Press the power button. Assuming you haven't reconfigured its behaviour, it should pop up a dialog with options to Sleep, Restart, or Shutdown the laptop. The "Reopen windows when logging back in" checkbox has keyboard focus by default; hitting the Tab key twice will put focus on the Sleep button - hitting the Space bar will then put the MacBook Air to sleep.

(Note that hitting Return will activate the dialog's default action - namely, to shut the computer down.)

Not as quick as a single keyboard shortcut, but faster than the mouse and without closing the lid. :)

2
8

Press the power button, then S.

As described in this thread:

https://discussions.apple.com/thread/3273071?start=0&tstart=0

The power button displays the Sleep/Restart/Shutdown dialog. If you then press S the Mac will sleep.

2
  • Nice! Two fewer keystrokes than my solution. :)
    – Dan J
    Oct 18, 2011 at 16:00
  • I would like to figure out if there is some rhyme or reason to the 'S' key activating the Sleep button. I wonder if there a consistent convention for which letters activate which buttons in osx.
    – ryanman
    Oct 18, 2011 at 16:05
4

Keyboard shortcut is Option+Cmd+Eject (the Eject key is at your keyboard upper right corner).

2
  • 5
    Not on the new MacBook Air models. No eject key.
    – Daniel
    Oct 18, 2011 at 2:30
  • 2
    The power key can be substituted for eject on Mountain Lion and later versions of OS X. It works for other shortcuts like ⌃⇧⏏ as well.
    – Lri
    Aug 29, 2012 at 5:33
3

Keyboard Shortcut

enter image description here

Sleep Mac while it is running

enter image description here

1
  • This just turns off the display on older Macs. On the newer Macs this is the same as sleep, as far as I understand, but it might confuse people with older machines.
    – Arne
    Aug 26, 2014 at 11:10
3

I was totally happy using Karabiner but:

Karabiner does not work on macOS Sierra at the moment.

I got bored of waiting so I solved by myself.

What I need? I need a command line to sleep mac, and this is pretty easy:

pmset sleepnow 

Who can I run the script? This is more boring, but not complicated:

  • open automator and create a new service

enter image description here

  • select 'run shell script' and write the above command

enter image description here

  • save with name "sleepService" and your are in!

Now the easy part: open System Preferences->Keyboard and type your custom shortcut!

enter image description here

2
  • This doesn't work for me. I can run pmset sleepnow from the cli and it works but it does not work as a service. I have tried both from within automator and not. Apr 16, 2018 at 21:49
  • @GregoryArenius check if you have any key binding conflicts.. Apr 17, 2018 at 12:50
1

For everyone without a mac keyboard, I advice you to install Karabiner.

Once opened, you can go under "Change Key" tab and search for sleep:

enter image description here

With this option checked, now you can:

  • prompt restart/sleep/shutdown dialog: CtrlAltDel
  • force immediately sleep: ShiftCtrlAltDel
1

Add below to karabiner complex modifications. You may adjust the shortcuts as you wish. They map to the original mac shortcuts for sleep screen and sleep computer.

Currently it is ctrl + option + command + button prior to 1 on keyboard (grave_accent_and_tilde)

Other is ctrl + option ... you know the rest.

{
        "description": "momomo.com.karabiner.sleep.screen.and.sleep.computer.shortcuts",
        "manipulators": [
                {
                        "type": "basic",

                        "from":  {
                                "key_code": "grave_accent_and_tilde",
                                "modifiers": {
                                        "mandatory": [
                                                "left_control",
                                                "left_option",
                                                "left_command"
                                        ]
                                }
                        },
                        "to": {
                                "consumer_key_code": "eject",
                                "modifiers": [
                                        "left_command",
                                        "left_option"
                                ]
                        }
                },

                {
                        "type": "basic",

                        "from":  {
                                "key_code": "grave_accent_and_tilde",
                                "modifiers": {
                                        "mandatory": [
                                                "left_control",
                                                "left_option"
                                        ]
                                }
                        },
                        "to": {
                                "consumer_key_code": "eject",
                                "modifiers": [
                                        "left_control",
                                        "left_shift"
                                ]
                        }
                }

        ]
},
0

Using Karabiner (previously named KeyRemap4MacBook), you can remap your F19 key (or any other F key for that matter) to make the computer sleep using the following private.xml:

<?xml version="1.0"?>
<root>
  <item>
    <name>F19 to Sleep</name>
    <identifier>Sleep</identifier>
    <autogen>
        __KeyToKey__
        KeyCode::F19,
        KeyCode::VK_CONSUMERKEY_EJECT, ModifierFlag::OPTION_L | ModifierFlag::COMMAND_L
    </autogen>
 </item>
</root>

To use a different F key, simply change all occurrences of F19 to something else.

F19 works best for me since it's at the top right edge of the full-size wired Apple keyboard, making it hard to hit it by mistake and easy to find in the dark.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .