Automatic keyboard detection

[endlessm/eos-shell#3425]
Please move the class declarations at the top of the function.