JSFiddle - React, Tailwind, and code Playground

by vural kaya

HTML

<input type="text" name="" value="[email protected]" id="input" />
<script type="text/javascript" src="http://www.uzmancevap.org/lib/javascript/jquery.min.js"></script>
	<script type="text/javascript" src="http://www.uzmancevap.org/lib/javascript/prefixfree.min.js"></script>

JavaScript

$("#input").keydown(function(e){ 
    if(e.which   == 8){
        var text = document.getElementById("input");
        var s = text.selectionStart;
        var e = text.selectionEnd;
        var harf = text.value.substr(s - 1, 1);
        var cokluSecim = text.value.substring(s, e);
        if ( s != 0 ) {
            if ( cokluSecim ) alert(cokluSecim);
            else alert(harf);
        }
    }
});