Hi Raushan, When a user hits a key on the keyboard, a client-side event is fired. The server is not used to capture or use this information as the server is simply recieving a request from the client (through the HTTP GET and POST protocols). Therefore you should focus on capturing and handling keyboard strokes on the client-side. The DOM's event object should provide you with the information you need when used in conjuction with the DOM onkeydown event (this is the event that is fired when a user hits a key). The following code shows an example of how to achieve this: Function to handle the key stroke: function checkKeyStroke(e) { var characterCode; if ( e && e.which ) { e = e; characterCode = e.which; } else { e = event; characterCode = e.keyCode; } if ( characterCode == 13 ) { // 13 is the ASCII character code for the enter key // Add logic here to handle the key stroke } } Attach it to the onkeydown event of the required element, in this case the body element: <body onkeydown="checkKeyStroke(event); ">
Clean code is the key to happiness.