Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Title says it all: how do I lock the screen using a keyboard shortcut on OS X Mountain Lion with a Microsoft Natural Ergonomic Keyboard 4000?

share|improve this question
Does your keyboard have an eject button? –  daviewales Dec 5 '12 at 22:32
As far as I can tell, it does not have an eject button. –  mattvonb Dec 5 '12 at 22:44

10 Answers 10

You do not need to use Third Party Apps to set a global short cut. You can use Automator Services,System Preferences keyboard Shortcuts and the CGSession -suspend command that switches to a login screen.

Use the Applescript :

do shell script "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -suspend"

in a Automator 'Service' like this with the set up as no input and all applications.

enter image description here

Save it and then go to the Keyboard System Preferences. -> Keyboard Shortcuts tab. Select Services on the right. And scroll down to the bottom on the left to 'General'. There you will see your service. Click the addShortCut. And give the service a shortcut. Clost system prefs.

enter image description here

You may need to quit some apps and re open them first for them to pick up the short cut for the first time. You can see the ones that have already picked it up..

enter image description here

Now try the shortcut from the keyboard.

share|improve this answer
I get really weird behavior in Mavericks with this method. –  diimdeep Oct 28 '13 at 15:56
weird behaviour like what?? –  markhunte Oct 28 '13 at 17:20
UI is freezing and completely broken like that dl.dropboxusercontent.com/u/609809/apple.stackexchange.com/… another time UI was broken too but different. –  diimdeep Oct 28 '13 at 20:16
+1, this introduces some really useful general knowledge too! thanks! –  gatoatigrado Mar 20 '14 at 21:33
@kermit666 yes. use: do shell script "/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.ap‌​p/Contents/MacOS/ScreenSaverEngine" –  markhunte May 14 '14 at 17:12

I used KeyRemap4Macbook to remap the pause/break key to eject. KeyRemap4Macbook is free, and it shows up in System Preferences after installing.

shift+ctrl+pause/break does the trick now.

screenshot from keyRemap4macbook

**Please note that KeyRemap4Macbook is now called Karabiner with the same functionality.

share|improve this answer

Assuming your keyboard has an eject button, you need to go to System Preferences, and click on "Security & Privacy", then click on the "General" tab, then select the checkbox that says "Require password immediately after sleep or screensaver begins". Now you can lock your computer by pressing Control-Shift-Eject. This puts the computer to sleep, but because we've told it to lock on sleep, it also locks it.

If your computer doesn't have an eject button, you will need to create your own custom shortcut. Unfortunately, you can only create shortcuts for menu items and services. Fortunately you can create a service to put the display to sleep (and thus lock the screen), and you can assign a shortcut to the service. For instructions on how to do this, see this Macworld page.

share|improve this answer
There is no eject button on the keyboard. (Or if there is, I cannot find it.) Also, I do not want the computer to sleep, only to be locked. –  mattvonb Dec 5 '12 at 22:43
You can replace the Eject button with the Power button. (If the keyboard has a power button...) –  daviewales Dec 5 '12 at 22:46
The keyboard also does not have a power button. –  mattvonb Dec 5 '12 at 22:48
There is an article here which shows you how to create your own custom shortcut. hints.macworld.com/article.php?story=20090831093941225 –  daviewales Dec 5 '12 at 23:09

You can easily add the padlock icon to your menu bar:

open /Applications/Utilities/Keychain\ Access.app/Contents/Resources/Keychain.menu

You can also add it through Keychain Access prefs. ;)

share|improve this answer

Or you can go to your Utilities Folder > Keychain Access > Preferences > Show keychain status in menu bar

This will put a lock in your menu bar and you can click "Lock Screen" to lock your screen. If you need a keyboard shortcut, you can add this in your keyboard under Settings.enter image description here

share|improve this answer
Could you clarify your last sentence? How does one add a shortcut? –  grgarside Mar 10 '14 at 19:20
I'd also like to ask how one creates a shortcut to this menu item - I've attempted to do this on the Keychain Access app, but I'm assuming the menu bar icon is not part of this app. –  Jim O'Brien Jun 24 '14 at 16:24

You can also log out to the fast user switching screen, but it doesn't turn off displays. Just assign a shortcut to this shell command:

/System/Library/CoreServices/Menu\ Extras/user.menu/Contents/Resources/CGSession -suspend

If you have the Alfred Powerpack, you can give the lock action a shortcut in the hotkeys tab:

share|improve this answer

Control+Shift+Eject is the keystroke for Macs with an Eject key, and for external keyboards Control+Shift+Power is the keystroke for Macs without the eject key, like the MacBook Air and MacBook Pro Retina


share|improve this answer
Where is the eject key on the Microsoft Natural Ergonomic Keyboard 4000? –  mattvonb Sep 19 '13 at 16:20

You can install the tiny, free SleepDisplay application, and assign it to any key in the Microsoft Keyboard section of System Preferences.

share|improve this answer

@markhunte's answer is good, but it falls short when you're in an app that doesn't have a "Services" menu (e.g., Calculator).

Instead of using System Preferences > Keyboard > Shortcuts to assign the shortcut, I use Apptivate: it's a free, lightweight utility whose only purpose is to run a command when you press a hotkey sequence.

Once you've created a "Lock Screen" service in Automator (as described by @markhunte's answer), you simply add it to Apptivate:

Empty Apptivate menu

When the "Open" dialog is displayed, press CMD+SHIFT+G (Go to Folder) and enter ~/Library/Services:

Go to Folder dialog

Then select the Automator service you created earlier:

Select Automator service

Finally, assign a keyboard shortcut to the service:

Apptivate keyboard shortcut menu

And that's it! Now you have a "Lock Screen" keyboard shortcut that can be used in any application.

share|improve this answer

There's a little app which does the trick — http://keylock.io

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.