hyo29 hyo29 - 4 months ago 38
Javascript Question

Overtype mode with jquery

How could I make my input field act as if the keyboard is in overtype mode?

I tried to trigger the keypress event with the delete button in keycode when the user enter a value but nothing happen.


Something like:

<input onkeydown="this.oldSize = this.value.length;" 
  onkeypress="var n = this; setTimeout(function() {
      if(n.value.length > n.oldSize) {
        var s = n.selectionStart;
        n.value = n.value.substr(0, s) + n.value.substr(s + 1);
        n.selectionStart = n.selectionEnd = s;