Extended SPACE Key Page Scroller

By default the SPACE key scrolls the page down by full height of browser view. With this script, pressing SHIFT+SPACE will scroll half of the view height. Page scroll by a quarter view height can be done using either LEFTSHIFT+RIGHTSHIFT+SPACE or SHIFT+CAPSLOCK+SPACE (configurable via variable).

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

You will need to install an extension such as Tampermonkey to install this script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Necesitará instalar una extensión como Tampermonkey para instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name         Extended SPACE Key Page Scroller
// @namespace    ExtendedSpaceKeyPageScroller
// @version      1.0.3
// @description  By default the SPACE key scrolls the page down by full height of browser view. With this script, pressing SHIFT+SPACE will scroll half of the view height. Page scroll by a quarter view height can be done using either LEFTSHIFT+RIGHTSHIFT+SPACE or SHIFT+CAPSLOCK+SPACE (configurable via variable).
// @author       jcunews
// @match        *://*/*
// @grant        none
// @run-at       document-start
// ==/UserScript==


// *** Configuration Start ***

// QuarterScrollKey: Determine what key combination to use for scrolling page by a quarter height of view.
// 0      = Use both SHIFT keys. i.e. LeftShift+RightShift+Space
// 1/else = Use CAPSLOCK key. i.e. Shift+CapsLock+Space
var QuarterScrollKey = 1;

// *** Configuration End ***


var shiftKeys = 0, capsLock = false;

addEventListener("keydown", function(ev) {
  switch (ev.which) {
    case 16: //SHIFT
      shiftKeys |= ev.location;
      break;
    case 20: //CAPSLOCK
      capsLock = true;
  }
}, true);

addEventListener("keyup", function(ev) {
  switch (ev.which) {
    case 16: //SHIFT
      shiftKeys &= ~ev.location;
      break;
    case 20: //CAPSLOCK
      capsLock = false;
  }
}, true);

addEventListener("keypress", function(ev, delta) {
  if (!ev.shiftKey) {
    shiftKeys = 0;
  } else if (!shiftKeys) {
    shiftKeys = 1;
  }
  if ((ev.which === 32) && !ev.altKey && (["INPUT", "TEXTAREA"].indexOf(document.activeElement.tagName) < 0)) {
    if (((shiftKeys === 3) && !capsLock && !QuarterScrollKey) || //with both SHIFT key
        (shiftKeys && (shiftKeys < 3) && capsLock && QuarterScrollKey)) { //with SHIFT+CAPSLOCK key
      delta = 4;
    } else if (shiftKeys) { //with one SHIFT key
      delta = 2;
    } else delta = 0;
    if (delta) {
      scrollBy(0, innerHeight / delta);
      ev.preventDefault();
      ev.stopPropagation();
      ev.stopImmediatePropagation();
    }
  }
}, true);