Firing a Keyboard Event in Safari, using JavaScript

前端 未结 5 1231
走了就别回头了
走了就别回头了 2020-11-22 05:22

I\'m trying to simulate a keyboard event in Safari using JavaScript.

I have tried this:

var event = document.createEvent(\"KeyboardEvent\");
event.in         


        
5条回答
  •  不要未来只要你来
    2020-11-22 06:14

    This is due to a bug in Webkit.

    You can work around the Webkit bug using createEvent('Event') rather than createEvent('KeyboardEvent'), and then assigning the keyCode property. See this answer and this example.

提交回复
热议问题