JSFiddle - React, Tailwind, and code Playground

HTML

<input>

JavaScript

$(function(){
    var key = 'dupa',
    chain = '';
    
    $(function(){
        $('input').on('keypress', function(e){
            chain += String.fromCharCode(e.keyCode);
            if(chain != key.substr(0, chain.length)){
                e.preventDefault();
                chain = '';
                $(this).val('')
            }else if(chain == key){
                alert('udalo sie')
            }
        })
    })
})