JSFiddle - React, Tailwind, and code Playground

by Chandana Thota

HTML

<!--code to get keyboard ascii codes-->
<!-- click inside textbox and then press arrows -->
<input type=text id="tbx">

CSS

#tbx{
    width:400px;
}

JavaScript

$('#tbx').keydown(function(pk){

  if(pk.keyCode == '37')
  {
    alert("Pressed left arrow key and ascii code is " + pk.keyCode);
  }
    if(pk.keyCode == '38')
  {
    alert("Pressed up arrow key and ascii code is " + pk.keyCode);
  }
    if(pk.keyCode == '39')
  {
    alert("Pressed right arrow key and ascii code is " + pk.keyCode);
  }
    if(pk.keyCode == '40')
  {
    alert("Pressed down arrow key and ascii code is " + pk.keyCode);
  }
  });