Ever wanted to lock your Mac à la Windows’ Win Key+L shortcut? There are other methods and apps to do this. But a keyboard shortcut would be the quickest way to do this task.
First, open System Preferences > Security. On the General section, check the “Require password after sleep or screen saver begins” checkbox. Select “immediately” from the pull down menu and close the window. I’m assuming that your Mac is password-protected.
Press Option+Command+Eject buttons. This shortcut will put your computer to sleep mode. Press any key to bring your system to wake state and you’ll be asked for your password.