Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What event is fired when text is cut or pasted (or ctrl+z'd) in a textarea?

I've been using keyup to detect when content in a textarea changes, but somehow Facebook can detect a Ctrl+X event in a textbox immediately when the X is pressed down. What event would this be?

like image 819
Nick Avatar asked Dec 19 '10 00:12

Nick


2 Answers

Most current browsers support cut, copy and paste events. Try the following to prove this to yourself:

<textarea oncut="alert('Cut!')" rows="3" cols="40"></textarea>
like image 66
Tim Down Avatar answered Nov 15 '22 07:11

Tim Down


I would guess they make a bind to the keydown, and set some sort of state variable when the control key is pressed, then when they receive a keyup event, they check the state variable and act accordingly.

like image 39
Samuel Avatar answered Nov 15 '22 07:11

Samuel