<input class="inputVal">
<script type="text/javascript">
    var myVal = document.getElementsByClassName('inputVal')[0]; 
    myVal.addEventListener('keyup', function(e){
        var count = myVal.value;
        console.log(count)
    });  
</script>
                Try bind event to document or window. If an element is not focusable and is not focused, keyboard events won't dispatch to it, instead they dispatch to document root(<body>).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With