How to simulate pressing the Z key inside a JavaScript event?

Question:

var ws = new WebSocket("ws://213.27.32.135:8100"); 
ws.onmessage = function(event) 
{
  Как здесь нажать клавишу "Z"?
}

Answer:

this is how it simulates, alert shows both on pressing Z and on 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 press?

Scroll to Top