Some keyboards come with dedicated buttons to sleep/turn off your system. I wanted to ‘lock’ my system via a single button, without putting it to sleep.
I have a Logitech keyboard so have the Logitech SetPoint software installed. There is an option to customise the special buttons on the keyboard via this software, but none of them offer the ability to lock the system.
However, there is an option to ‘launch a program’ and if you enter: %windir%\System32\rundll32.exe user32.dll,LockWorkStation in the path field (Program:) then this allows you to lock the computer with a single press of a keyboard button.