javascript - How do you make a rectangle(HTML element) controllable with the arrow keys? -
How do you create a rectangular or other HTML element, but for example say a rectangle may be able to rotate around it The movement is controlled by the arrow keys (e.kcode and case #) and then how can you create spaces, can not go into the rectangle?
"post-text" itemprop =
"text">
.
$ (document) .ready (function () {$ (document) .keydown (function (e) {// left arrow if (e.wich == 37) {$ ('# box') CSS ('left', '- = 1')}} // top arrow if (E. == 38) {$ ('# box'). CSS ('top', '- = 1'); } / Right arrow if (E. ==339) {$ ('# box'). Css ('left', '+ = 1');} / / down arrow if (E. == 40) { $ ('# Box'). CSS ('top', '+ = 1');}})}};
You can see the encoded.
He said, the best way to do this was to use HTML5 canvas. It was a quick demonstration with a div.
Comments
Post a Comment