YouTube ShortsKeys

Adds ArrowRight and ArrowLeft keys to YouTube Shorts same as ArrowUp and ArrowDown!

  1. // ==UserScript==
  2. // @name YouTube ShortsKeys
  3. // @namespace YouTubeShortsKeys
  4. // @version 2.0.1
  5. // @description Adds ArrowRight and ArrowLeft keys to YouTube Shorts same as ArrowUp and ArrowDown!
  6. // @author Runterya
  7. // @homepage https://github.com/Runteryaa
  8. // @match *://*.youtube.com/shorts/*
  9. // @match *://*.youtube-nocookie.com/shorts/*
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
  11. // @grant none
  12. // @license MIT
  13. // @compatible chrome
  14. // @compatible edge
  15. // @compatible firefox
  16. // @compatible opera
  17. // @compatible safari
  18. // ==/UserScript==
  19.  
  20. console.log("YouTube ShortsKeys");
  21.  
  22. document.addEventListener('keydown', function(event) {
  23. console.log("Keydown event detected:", event.key);
  24. if (event.key === 'ArrowRight') {
  25. console.log("Right arrow key pressed. UP!");
  26.  
  27. const upArrowEvent = new KeyboardEvent('keydown', {
  28. key: 'ArrowUp',
  29. code: 'ArrowUp',
  30. keyCode: 38,
  31. which: 38,
  32. bubbles: true,
  33. cancelable: true,
  34. composed: true
  35. });
  36.  
  37. console.log("Simulating up arrow key press.");
  38. document.dispatchEvent(upArrowEvent);
  39.  
  40. console.log("Up arrow key event dispatched.");
  41. }
  42. });
  43.  
  44. document.addEventListener('keydown', function(event) {
  45. console.log("Keydown event detected:", event.key);
  46. if (event.key === 'ArrowLeft') {
  47. console.log("Left arrow key pressed. DOWN!");
  48.  
  49. const downArrowEvent = new KeyboardEvent('keydown', {
  50. key: 'ArrowDown',
  51. code: 'ArrowDown',
  52. keyCode: 40,
  53. which: 40,
  54. bubbles: true,
  55. cancelable: true,
  56. composed: true
  57. });
  58.  
  59. console.log("Simulating down arrow key press.");
  60. document.dispatchEvent(downArrowEvent);
  61.  
  62. console.log("Down arrow key event dispatched.");
  63. }
  64. });
  65.  
  66. document.addEventListener('keydown', function(event) {
  67. console.log("Captured event:", event.key);
  68. });