Somewhat imperfect comparison: in Windows, you can simply press Win+L to lock Windows.
Is there a similar keyboard shortcut in Android?
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It only takes a minute to sign up.Sign up to join this community
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 on your machine.
A complete ADB installer in 15 seconds for Windows can be found here: [XDA Forums - [OFFICIAL]TOOL][WINDOWS] ADB, Fastboot and Drivers - 15 seconds ADB Installer v1.4.3.
And for Linux machines, there is a script which is written by Corbin Davenport. Just execute the following command without the quotes in any Linux terminal to install
bash <(curl https://raw.githubusercontent.com/corbindavenport/nexus-tools/master/install.sh)
Hope this helps you although this is not a shortcut key.
There is no way to lock the device using the keyboard.
If you want the same effect that your computer has when it locks on your phone (i.e. needing a password next time you log in), then go to Settings, Lock screen, and set it to require a password (or whatever you use) whenever you wake your phone.