JSFiddle - React, Tailwind, and code Playground

by Tom Randolph

HTML

<input placeholder="Type the @ symbol" />

JavaScript

$(function(){
    $( "input" ).on( "keydown", function( e ){
        var p = $(this).siblings( "p" ),
            key = e.keyCode || e.which;
        
        p = p.length ? p.first() : $( "<p></p>" );
        
        if( key === 50 ){
            if( !e.shiftKey ){
                p.html( "You typed '2'" );
            }
            else{
                p.html( "You typed '@'!" );
            }
        }
        else{
            p.html( "You typed something else:" + key );
        }
        
        $(this).after( p );
    });
});