var ws = new WebSocket("ws://213.27.32.135:8100"); ws.onmessage = function(event) { Как здесь нажать клавишу "Z"? } |
1 answer
imitates this way, the alert shows when you click on Z and the onmessage event
var e = jQuery.Event( "keypress", { which: 122 } ); window.onkeypress = function(event) { if(event.which == 122){alert("ok")} } var ws = new WebSocket("ws://213.27.32.135:8100"); ws.onmessage = function(event) { КакjQuery( здесь"body" нажать).trigger( клавишуe "Z"?); } Can anyone tell me why the flash does not respond to such a click?
- Flash itself, why should it respond to jQuery with which it is not connected? - Grundy
- when i click on the keyboard Z, the button in the flash is pressed, when i imitate the click in javascript is not the same click? - ArtGrek13
- No, not the same. - Grundy
- and how to do the same? - ArtGrek13
- In general, no way. And this is good, since it allows to distinguish a program event from an event from a real keyboard. In the case of a flash drive, if it is yours, then you need to pull out the function that is performed by pressing
Zand call it directly from js, without any trigger. If there is no access to the flash drive code, then, most likely, there is no way. - Grundy
|
Как имитировать нажатие клавиши- I wrote you - Alexey Shimansky