Automatic keyboard detection

[endlessm/eos-shell#3425]
Coding style: in this case should use curly braces for both branches.