Cancel the keydown in HTML

后端 未结 6 917
清歌不尽
清歌不尽 2020-11-29 10:28

How can I cancel the keydown of a specific key on the keyboard, for example(space, enter and arrows) in an HTML page.

6条回答
  •  独厮守ぢ
    2020-11-29 10:44

    Catch the keydown event and return false. It should be in the lines of:

    
    

    (seen here)

    The keycodes are defined here

    edit: update my answer to work in IE

提交回复
热议问题