HashMap<String, Integer> keyObj = new HashMap<String, Integer>();        
keyObj.put("keycode", 26);
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("mobile:keyevent",keyObj);
try {
    Thread.sleep(5000);
     } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
}
js.executeScript("mobile:keyevent",keyObj);

keyObj.remove(26);
keyObj.put("keycode",  1);
js.executeScript("mobile:keyevent",keyObj);


↙↙↙阅读原文可查看相关链接,并与作者交流