Page content: Text box simulation keyboard Click on the div element to achieve mobile;
<body><textarea id="myarea" ti></textarea>" mydiv "title="dddddiv"></div></body>
The div style can be defined by itself;
The JS script code is as follows:
Div moves to the left 10px when the keyboard enters ' a ' or ' a '
Script type= "Text/javascript" >varMyarea = document.getElementById ("Myarea");varMydiv = document.getElementById ("mydiv");//Event is a keyboard events object that can recognize which key is pressed aftervarA =Mydiv.offsetleft;//var a = mydiv.offsetwidth;//var a = window.getComputedStyle (mydiv). Left;Myarea.onkeypress =function(event) {//alert (event.keycode);//var odiv = document.getElementById ("mydiv");//Alert (Odiv.getattribute ("title"));if(Event.keycode = = "All" | | event.keycode = = "97") {a=a-10;//var B = a + "px";//alert (a);vari = "20px"Mydiv.style.left= a + "px";}}</script>
JS to move through the keyboard click event to achieve DIV