Programmatically sending keys to input field?

前端 未结 4 1493
醉梦人生
醉梦人生 2020-12-11 01:30

I\'m coding a web-portal for a set top box with a custom keyboard.

The keyboard has most of the standard character keys but no backspace!

Since there are som

4条回答
  •  [愿得一人]
    2020-12-11 02:07

    Assuming the browser supports the W3C event model, you can create a KeyEvent and dispatch that using the dispatchEvent method of the input field. There's an example (using MouseEvent) over on mozilla.org. There are also some more links over where I last answered this question ;-)

    UPDATE: the following code has been tested in Firefox 3.5, and successfully backspaces through the characters in the text field:

    
    
    
    
    Insert title here
    
    
    
    
    
    

提交回复
热议问题