The fastest way to lock your screen a modern Mac is to use the key combination
Using an external PC keyboard is a more tricky because it probably won’t have either a power or eject button. To get one working, install Karabiner and remap Pause/Break to Power:
Break will now trigger the lock.
Power used to be
Eject, but then Macs started shipping without optical
Fast OSX screen lock
January 22, 2016
Find me on Twitter at @brandur.
Did I make a mistake? Please consider sending a pull request.