Capture Copy / Paste / Select in Javascript

How can I write the following keys in Textboxusing JavaScript?

Ctl + a

Ctl + c

Ctl + v

Below is the initial situation.

I have three Textboxesfor phones. Textbox1the maximum length is 3, the second is 3, and the third is 4. When the user enters three digits in Textbox1, the cursor automatically moves to TextBox2the same thing happens with TextBox2, as well as with TextBox3. I handle this functionality in a keyup event. Now, I use your code in parallel. But it also goes to the keyup event. This happens when all text fields are filled. Now suppose I am in TextBox1 and presses Ctl + A. This moves the user to the third TextBox (unacceptable case). This is problem.

+3
source share
3 answers

Use events select, copyand pasteaccordingly. Today it is very versatile.

var textBox = document.getElementById("textBoxId");
textBox.onpaste = function() {
    alert("paste");
};

Similarly for other events. Demo here: http://jsfiddle.net/timdown/EC2Hf/

+6
source

What about a right click, osx that doesn't use controls, an editing option in the browser, a button on my old keyboard, etc.?

There is more than just keystrokes.

However, most browsers support

oncopy and onpaste events.

+1
source

, ctrl, .

0
source

All Articles