Advertisement
snegir

js tab

Mar 19th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. (function() {
  2.  
  3. var tabKeyPressed = false;
  4.  
  5. $(document).keydown(function(e) { //вместо document тут и ниже, можешь поставить селектор формы
  6. tabKeyPressed = e.keyCode == 9;
  7. if (tabKeyPressed) {
  8. e.preventDefault();
  9. return;
  10. }
  11. });
  12.  
  13. $(document).keyup(function(e) {
  14. if (tabKeyPressed) {
  15. alert('tab') //тут можно вставить dataLayer для автоэвента
  16. e.preventDefault();
  17. return;
  18. }
  19.  
  20. //Do other stuff when not TAB
  21. });
  22.  
  23. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement