64

I'd like to press a key combo to get my computer to the lock screen. In Windows the shortcut was Windows key + L. On Mac I press CMD+ALT+Power 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.

80

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.

  • 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. – Ashutosh Jindal Sep 9 '15 at 8:11
  • Thanks, I have updated the answer to include the language change between versions. – hoss Sep 9 '15 at 20:13
  • A slight typing mistake .."Show Status in Menu Bar" should be "Show keychain status in menu bar". – codevscolor Oct 7 '15 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 Oct 7 '15 at 13:35
  • Another option that I use is the free quick launcher Alfred (free), which includes a Lock command. alfredapp.com – Taylor Edmiston Jan 3 '16 at 19:19
20

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.

  • 3
    @eveo this is the same as control+shift+eject. Display sleep, but not computer sleep. – cde May 15 '16 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.). – Trevor Sullivan Feb 24 '17 at 23:50
  • 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". – Bogdan Calmac Mar 13 '17 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 Apr 30 '17 at 21:24
3

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
    Yeah, I don't want it blacking my screen and keyboard out. I thought I made that clear in the OP. – eveo Jul 9 '13 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.

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.
0

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".

You must log in to answer this question.

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