Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. /*
  2. reomve text ('_copy') from focused input on keypress (CTRL + Q)
  3.  
  4. */
  5.  
  6. function stripFocus(text){
  7. const input = document.activeElement;
  8. var inputText = input.value;
  9. var re = new RegExp(text, 'g');
  10. inputText = inputText.replace(re, '');
  11. input.value = inputText;
  12. }
  13. document.onkeydown = function(evt) {
  14. evt = evt || window.event;
  15. if (evt.ctrlKey && evt.keyCode == 69) {
  16. stripFocus('_copy');
  17. }
  18. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement