title: WebSocket event when pressing keyboard
body: <p>I try to make the client side send a char to the server whenever a specific keyboard is press</p>
  
  <p>Here my code: </p>
  
  <pre><code>var connection = new WebSocket('ws://localhost:8001');
  
  $(document).keypress(function(e){ // pressing key 
    if(e.keyCode == 119){ // w 
      $("#d-up").css("background-color","#404d4d","opacity","50%"); // hover effect 
        connection.onmessage = function (event) {  //websocket event 
          connection.send("W");
        };
      }
  });
  
  $(document).keyup(function(e){  
      $(".button").css("background-color","#1d2323");
    });
  </code></pre>
  
  <p>The server and client is connected but no message was send when i press the w. Appreciate you help. </p>
  
  <p>Thank you  </p>