Ctrl+C Ctrl+V Javascript

Copy (Ctrl+C) Paste (Ctrl+V) Javascript key event handling.

Copy Ctrl+C

event.ctrlKey && event.keyCode == 67

 4
 5
 6
 7
 8
 9
10
11
  var myinput = document.getElementById("myinput");

  myinput.addEventListener("keydown", function(event) {
    ...
    if (event.ctrlKey && event.keyCode == 67) {
    ...
    }
  });

Paste Ctrl+V

event.ctrlKey && event.keyCode == 86

 4
 5
 6
 7
 8
 9
10
11
  var myinput = document.getElementById("myinput");

  myinput.addEventListener("keydown", function(event) {
    ...
    if (event.ctrlKey && event.keyCode == 86) {
    ...
    }
  });

Add

In addition, if you access keycode.info and input the key you want to know, you can find the keycode immediately.

That’s all. Congratulations! 👏