jquery keydown preventDefault not working on Android

274 views Asked by At

Here is my jsfiddle link

var maxLen = 3;
$('#txt_my').keydown(function(e) {
  var Length = $(this).text().length;
  if (Length >= maxLen && e.keyCode != 8) {
    e.preventDefault(); // will cancel the default action of the event
  }
});
<div id="txt_my" contenteditable="true">h</div>

https://jsfiddle.net/yupok/nrmcg0L6/

This above link is working on desktop browsers but not working in any android.

0

There are 0 answers