Is there a way to lock an Android device using a keyboard? Somewhat imperfect comparison: in Windows, you can simply press Win+L to lock Windows.

Is there a similar keyboard shortcut in Android?
You could type in "adb shell input keyevent 26" which in turn will lock your screen

For this you need the usb debugging enabled on your phone and adb should be installed in your machine 

A complete adb installer in 15 seconds for windows can be found here

Reference :http://forum.xda-developers.com/showthread.php?t=2588979

And for Linux Machine there is a script which is written by Corbin Davenport. just execute below given line without the quotes in any Linux terminal to install

"bash &lt;(curl https://raw.githubusercontent.com/corbindavenport/nexus-tools/master/install.sh)"

Hope this helps you although this is not a shortcut key