73

I'd like to press a key combo to get my computer to the lock screen. In Windows the shortcut was Windows keyL. On Mac I press CMDALTPower which turns the laptop off and puts it into sleep. I want to just have it go to the lock screen with the monitor staying on.

1

9 Answers 9

88

High Sierra and higher(?)

As usual every system update changes something. There is now a Apple Menu item control++Q that locks the screen!

Sierra and lower

You can add the Lock Screen to your Menubar.

  • In Spotlight ( + Space) search for Keychain Access

  • Open Preferences ( + ,)

  • Check Show keychain status in menu bar This will show a lock in your Menu Bar with an option Lock Screen

    (Optional)

  • System Preferences > Keyboard > Keyboard Shortcuts or Keyboard Tab

  • In the App Shortcuts or Application Shortcuts section, add a new item for All Applications with the Menu Title of Lock Screen and a Keyboard shortcut that you like. Example

This way you don't have to change your Screensaver timeout and you can lock your machine much like you do in windows. Note that You may also need to Logout and back in for any changes to the shortcut to take effect.

9
  • 1
    A small addition for Yosemite. To add the keyboard shortcut as in the second half of hoss' answer go to System Preferences -> Keyboard -> Shortcuts, click on App Shortcuts -> All Applications and then add the keyboard shortcut as above. Commented Sep 9, 2015 at 8:11
  • Thanks, I have updated the answer to include the language change between versions.
    – hoss
    Commented Sep 9, 2015 at 20:13
  • A slight typing mistake .."Show Status in Menu Bar" should be "Show keychain status in menu bar".
    – N Kaushik
    Commented Oct 7, 2015 at 7:07
  • Depends on the version of the OS, apple likes to change the language slightly between releases. However you are right, starting from at least 10.9 it was changed to 'Show keychain status in menu bar'
    – hoss
    Commented Oct 7, 2015 at 13:35
  • 1
    Another option that I use is the free quick launcher Alfred (free), which includes a Lock command. alfredapp.com Commented Jan 3, 2016 at 19:19
25

I have finally figured out how to do this:

pmset displaysleepnow

That will actually put the display to sleep without suspending the entire machine.

Amazing how hard it is to figure out how to do something so basic.

5
  • 3
    @eveo this is the same as control+shift+eject. Display sleep, but not computer sleep.
    – cde
    Commented May 15, 2016 at 0:48
  • Mac OS X seems to have different ways of doing everything, which is kind of frustrating. I want to like it, but one of the huge benefits of Windows is having common APIs for many different types of operations (eg. WMI, performance metrics, etc.). Commented Feb 24, 2017 at 23:50
  • 1
    Is there an equivalent for the MacBook (which doesn't have an eject key)? On my Sierra 10.12.3, the Ctrl+Shift+Power shortcut puts the laptop to sleep. I see that because the VPN gets disconnected. This doesn't happen for "pmset displaysleepnow". Commented Mar 13, 2017 at 20:52
  • Also, to make it so you can run this with a keystroke, use Automator to create a service. I did something like this arstechnica.com/apple/2011/03/… Once you have that you can give it a shortcut in the Keyboard settings. And totally non-intuitive, of course. I've had to reconfigure my macbook twice and each time I had to go google this up again.
    – BHS
    Commented Apr 30, 2017 at 21:24
  • @BHS I have been looking for this for years, thanks! If I change my sleep settings to "never" sleep, in combination with this can I be assured that any processes I have running in background keep running while displaysleep is ON? On my MBP, this also locks the screen, which is awesome!!! That way I can keep working on the machine which is in sleep via a ssh connection, and not worry about burning extra power.
    – codepoet
    Commented Sep 21, 2021 at 9:06
8

This is now built into High Sierra.

The keyboard shortcut is CTRL++Q

3

I use BetterTouchTool to do just this. Once downloaded and running:

  1. Click the "Keyboard" tab and select "Global" in the left-hand "Select Application" pane
  2. Click "+ Add new keyboard shortcut" at the bottom of the shortcut list
  3. Click the "Keyboard shortcut" recording field and hold down the keys you wish to use for the shortcut, I use + L (which feels most like the Windows key + L on Windows systems)
  4. Click the "Trigger predefined action" dropdown and select "Open application/file/script..."
  5. Navigate to /System/Library/Frameworks/Screensaver.framework/Versions/A/Resources and select "ScreenSaverEngine.app" and click "Open"

Alternatively, instead of steps 4 and 5, click the "Trigger predefined action" dropdown and select "Lock Screen" which locks the screen without triggering the screensaver.

Now hitting + L will trigger the screensaver (and lock the computer, provided you followed the advice in the answer from @Buscar 웃 above to require the password when the screen saver or display sleep begins). You can also set BetterTouchTool to launch when the computer starts so your hotkey always works.

2

First, you should enable requiring the password when the screen saver or display sleep begins.

To do that go to

screenshot of Security & Privacy > General

Now, when you press the key combination control+shift+power (control+shift+ on some systems) to put the screen to sleep, it will also lock the screen.

1
  • 1
    Yeah, I don't want it blacking my screen and keyboard out. I thought I made that clear in the OP.
    – eveo
    Commented Jul 9, 2013 at 15:00
1

Quoting myself from https://github.com/tjluoma/lockscreen:

  1. Download and install FastScripts (which is free for up to 10 keyboard shortcuts)

  2. Download and install LockScreen.scpt and save it to ~/Library/Scripts/ (you may have to create that folder if you haven't used it before.

  3. Assign the keyboard shortcut of your choice to LockScreen.scpt within FastScripts preferences:

FastScripts preferences screenshot

Note: while the OP did not want to sleep the screen display, that can easily be done too. Just download Sleep Display and install it to /Applications/ and use SleepAndLockScreen.scpt instead of LockScreen.scpt.

1

There is a wonderful tool Karabiner that can help you with this (and many more):

Properties->Misc&Uninstall -> private.xml

<root>
<!-- Place this file to ~/Library/Application Support/Karabiner/private.xml -->
  <item>
      <item>
        <name>Screensaver Lock screen (Ctrl-Cmd-L)</name>
        <identifier>myconfig.lock</identifier>
        <autogen>__KeyToKey__ KeyCode::L, ModifierFlag::CONTROL_L | ModifierFlag::COMMAND_L,
                                KeyCode::VK_OPEN_URL_APP_ScreenSaverEngine</autogen>
      </item>
  </item>
</root>

Then activate the Screensaver Lock screen (Ctrl-Cmd-L) in the Change Key screen.

Update [1 Feb 2018]: The Karabiner was deprecated and replaced with Karabiner-elements. So achieving this may be as simple as mapping the MAC POWER button to some button on the keyboard. I use PAUSE button for that. Then locking screen would be Ctrl-Shift-Power and suspending - Cmd-Opt-Power.

1

I can recommend using Hot Corners: System Preferences -> Desktop & Screen Saver -> Hot Corners (in the bottom right corner). There you can select an option for the corner you want to. "Lock Screen" or "Put Display to Sleep".

0

Logging out to the fast user switching screen:

  • Add a shell alias or a keyboard shortcut for /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend.
  • Enable the fast user switching menu from the Users & Groups preference pane, and then select Login Window… from the menu.
  • Use the lock action in Alfred.

Locking the screen:

  • Check "Require password immediately after sleep or screen saver begins" in the Security & Privacy preference pane. You can then lock the computer manually by pressing control-shift-eject to turn off displays, by pressing option-command-eject to go to sleep, or by running open -a ScreenSaverEngine.
  • Enable the Keychain menu extra in the preferences of Keychain Access, and then select Lock Screen from the menu.

You must log in to answer this question.

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