1

I'm listening to changes in a textbox using keyup and change as the events. This works when you type with the keyboard or do a copy paste also with the keyboard (Ctrl-V).

The problem is that when a user right-clicks on the textbox and pastes text, the change is not detected until the user clicks somewhere else on the page, and so things look broken. Here's the jsFiddle and here's the code:

function Start() {

    $('#test').on({
    change: OutputTxt,
    keyup: OutputTxt
  })
}

function OutputTxt() {
    $('#output').text($('#test').val());
}

$(Start);

How do I change this so that a change that occurs with copy-paste is detected as soon as the pasting is done. Note: I tried adding a click event but it doesn't help.

frenchie
  • 51,731
  • 109
  • 304
  • 510
  • Possible duplicate of [How to detect right mouse click + paste using JavaScript?](http://stackoverflow.com/questions/441631/how-to-detect-right-mouse-click-paste-using-javascript) – Jacques ジャック Dec 30 '15 at 02:15

1 Answers1

3

Try on input:

    $('#test').on({
        input: OutputTxt,
      })
andyf
  • 3,262
  • 3
  • 23
  • 37