Apps How To Windows 10

Disable Spacebar Pagedown Scrolling YouTube in Chrome and Firefox

How many times have you meant to pause a video on YouTube using the pacepacebar, only to find yourself jumping down to the comments section instead? A simple extension will remedy this for you on Firefox and Chrome in no time!

Space

Spaaaaaaace

Listening to music in the background is very good for the soul when you are working your typical 9-5 job in your cubicle. Some people use various apps for this but there are those who use YouTube on loop. At times it can be inconvenient when, instead of pausing your video, pressing the spacebar makes you jump to the comments section and delay the pausing of the video.

One might think that the problem is unsolvable there is indeed a relatively simple and easy fix to the above scenario which will not only work for YouTube but can also work on other sites where you would wish to disable pagedown scrolling with the use of spacebar.

To begin, you will need to download Tampermonkey / Greasemonkey on Google Chrome / Mozilla Firefox respectively. You can find download links to both from their respective stores below:

Tampermonkey for Google Chrome [Chrome Webstore]

Greasemonkey for Mozilla Firefox [Mozilla Add-ons]

For this guide, we will be using Tampermonkey on Google Chrome, but the process will be relatively the same on Mozilla Firefox too.

From here on, the guide will continue assuming you have downloaded and installed the extension on your respective web browser of choice.

Also check out: Seer – press spacebar to view large preview of any file in Windows

STEP 1: 

Once you have downloaded and installed the extension using the Chrome Webstore, you will see the extension added to the extensions panel in your browser.

Running the extension.

You will now click on the extension and choose the option of “Add a new script…

Adding a new script.

STEP 2: 

You will now copy and paste the following line of script from below and paste it to the body.

// ==UserScript==
// @name Disable space bar scrolling
// @namespace Disable Space bar scroll
// @version 0.1
// @description disable space bar scroll
// @author Space bar scroll
// @match https://www.youtube.com/*
// @grant none
// ==/UserScript==

(function() {
var k = function(action){
var eventObj = document.createEvent(“Events”);

eventObj.initEvent(“keydown”, true, true);
eventObj.keyCode = 75;
eventObj.which = 75;

document.body.dispatchEvent(eventObj);
};

var killSpaceBar = function(evt) {

var target = evt.target || {},
isInput = (“INPUT” == target.tagName || “TEXTAREA” == target.tagName || “SELECT” == target.tagName || “EMBED” == target.tagName);

// if we’re an input or not a real target exit
if(isInput || !target.tagName) return;

// if we’re a fake input like the comments exit
if(target && target.getAttribute && target.getAttribute(‘role’) === ‘textbox’) return;

// ignore the space and send a ‘k’ to pause
if (evt.keyCode === 32) {
evt.preventDefault();
k();
}
};

document.addEventListener(“keydown”, killSpaceBar, false);

})();

When you have done so, your script will look like the following image below.

A look at the script.

When you have successfully copy-pasted the code, you will simply need to left-click the floppy disk icon in the image to save your work.

STEP 3: 

You will be sent to this page and from here, you simply need to move your mouse to the toggle next to the 1 (To the right of it) and switch it from Off to On.

Enabling the script

This will put the script into immediate effect and will make your spacebar exclusively the pause button of your YouTube videos.

BONUS OPTIONAL STEP if you want to use the above guide on websites other than YouTube:

If you wish to replicate the above steps but for sites that aren’t YouTube, you will follow the above steps till Step 2, but this time, you will stop at Line 7 of the script (At least in the image which I have posted).

You will look for the single line of code:

// @match https://www.youtube.com/*

This is where you will enter the website you wish to enable the feature on as well so that pressing spacebar will prevent the page from scrolling down.

It is recommended that after you carry out the above steps to close and re-open the browser at least once. A system restart is not necessary at all to save the changes.

Alternatively, if you can build up the habit to, You can also press the K key on your keyboard to pause / play videos on YouTube without scrolling down accidentally. Unfortunately, it is very unlikely for you to develop the habit of this due to the muscle memory of videos and the spacebar key.

We hope that you found this guide to be of use to you and help remedy your troubles using the spacebar on websites. Let us know in the comments section if you want to see more guides like this!

(via AddictiveTips)

  • Elisa

    OMG THANK YOU I didn’t know what happened but this morning suddenly my space bar was scrolling while it wasn’t the case before.
    I replace the url by https://trello.com/ and it works!!