This article was reproduced from: http://www.cnblogs.com/sh1o2os/archive/2013/02/05/2893201.html
Sometimes when it comes to development, the touchscreen we use does not have virtual keys (HOME, back, menu, etc.), but when we use the Android system and sometimes want to quit an app or return, you can use input keyevent in the background to simulate key events. If you are using ADB, enter the command:
$ADB Shell Input KeyEvent 4//Analog return key (back)
$ADB Shell Input keyevent 82//Analog Menu key
$ADB Shell Input KeyEvent 3//Analog Home key (home)
If you have used the $ADB shell into the background, or a serial port into the background, then the above command does not adb shell, directly $input keyevent key value on the line.
Other key values can be queried under their own, here is the introduction of the three most familiar to the common.
Android background Input command simulates button "Go"