How to take keyboard input in JavaScript?

前端 未结 5 2043
醉梦人生
醉梦人生 2020-12-02 08:50

I want to take keyboard input in JavaScript, where arrow keys, when pressed, will result in the change in shape of a particular shape. How do I take the input of any of the

5条回答
  •  悲哀的现实
    2020-12-02 09:39

    If you are doing this in a browser, you can capture keyboard events.

    • keydown
    • keypress
    • keyup

    Can all be listened to on HTML nodes in most browsers.

    Webkit also supports...

    • textInput

    See for more details .. http://unixpapa.com/js/key.html

提交回复
热议问题