How to create hotkeys for Windows sleep and shutdown

Your computer has one, and maybe two, special buttons that you can configure for just these purposes. In addition, you can create shortcuts for these tasks, and assign hotkeys to the shortcuts.
Let’s start with the special buttons that already exist.
In Windows 7, click Start, or in Windows 8, go to the Search charm. Once there, type power, and select Power Options. In the resulting Control Panel window’s left pane, select Choose what the power buttons do.
How many options you’ll find will depend on your computer. If you have a desktop, you can assign actions to the Power button and the Sleep button.
0210-desktop-power-options
If you have a laptop, you’ll also have a “When I close the lid” option, and you’ll have all three options twice—for On battery and Plugged in.
0210-laptop-power-options-02
The Power button, of course, is the one you press when you turn on your PC. You may or may not have a sleep button on your keyboard. To find out, look for a key with a crescent-moon icon. With a laptop, Sleep probably involves holding down the Fn key while you press another key. If you can’t find a Sleep key on your keyboard, check the keyboard documentation to see if there’s a way to reassign another key for that purpose. It’s possible that you simply don’t have that option.
If you need more power hotkeys (likely if you don’t have a Sleep key), you can create your own.
First, create a shortcut: Right-click an empty space on the desktop and select New>Shortcut. On the only field available on the resulting wizard, enter the appropriate command:

  • Shut down: Shutdown.exe -s -t 00
  • Reboot: Shutdown.exe -r -t 00
  • Lock: Rundll32.exe User32.dll,LockWorkStation (and yes, that one works on 64-bit systems)
  • Hibernate or Sleep: rundll32.exe powrprof.dll,SetSuspendState 0,1,0

If the Hibernate option is turned on, that last command will hibernate the PC. Otherwise, it will put it to sleep.
To control that setting in Windows 7, click Start, type cmd, right-click cmd.exe, and select Run as administrator. In Windows 8, go to the Search charm, type cmd, right-click Command Prompt and select Run as administrator.
At the resulting command prompt, type powercfg -hibernate off or powercfg -hibernate on, then press ENTER.
Now that you’ve created a shortcut, let’s turn it into a hotkey: Right-click the shortcut and select Properties. On the Shortcut tab, click the Shortcut key field. Press a key. Windows will automatically prefix it with Ctrl-Alt, lessening the likelihood of accidentally turning off your computer.
And believe me, if there’s on thing you don’t want to do, it’s accidentally turning off your computer.