Getting events when deleting and pasting into jquery text box

I am using jquery on asp.net mvc. I have a text box on the page, and I hooked up a handler for the keyup event from the text box. When a user deletes text or inserts text into it, I do not call the handler.

Please help me how to handle this.

EDIT: I also want to get the value when the user inserts the value with the mouse.

+3
source share
2 answers
<input type="text" id="mytextbox" />

<script type="text/javascript">
  $(document).ready(function () {
     $("#mytextbox")keyup(function(evt) {
       evt = evt || event;
       switch (evt.keyCode) {
          case 8: //Backspace was pressed
            alert("Backspace");
            break;
          case 46: //Delete was pressed
            alert("Delete");
            break;
          case 67:
            if (evt.ctrlKey) {
               alert("Ctrl-C");
            }
            break;
          case 86:
            if (evt.ctrlKey) {
              alert("Ctrl-V");

            }
            break;
          default:
            alert(evt.keyCode);
            break;
       }
     });
  });

</script>
+2
source

Try moving keyupto changeand see if this helps.

- EDIT -

http://archive.devx.com/dhtml/articles/nz012402/nz012402-6.asp. .

0

Source: https://habr.com/ru/post/1750681/


All Articles