JSFiddle - React, Tailwind, and code Playground

by KelseyW

HTML

Key Down: <input type="text" id="keyDown" /> &nbsp;
Key Pressed: <input type="text" id="keyPress" />&nbsp;
Key Up: <input type="text" id="keyUp" />

JavaScript

$(function () {
    var $kp = $('#keyPress');
    var $kd = $('#keyDown');
    var $ku = $('#keyUp');
    var counter = 1;
    
    $(document).on ('keypress', function (e) {
        $kp.val(e.which);
    }).on('keydown', function (e) {
        $kd.val(e.which);
    }).on('keyup', function (e) {
        $ku.val(e.which);
    });
    
    
    
});