Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I would like to emit a CtrlS keydown event using JavaScript. Ideally the solution works in most modern browsers (up to IE 9).

I am writing tests and need to test my handler for key bindings. CtrlS is just an example, it can be any key binding with a modifier key. I know about the keyEvent.initKeyboardEvent() method but I was not able to use it correctly to trigger the same event I got when printing out the full keyboard event after pressing the key from the keyboard.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
744 views
Welcome To Ask or Share your Answers For Others

1 Answer

I would like to emit a CtrlS keydown event

You mean, in order to trigger the browser's "Save as" dialog or something? That's not possible for security reasons. It would be a huge security problem if it were - imagine: every web site could arbitrarily trigger browser functions.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...