Arrow key shortcut misfires

Every so often after I cast votes, something will change because the browser picked up an arrow key and moved a vote. It hasn’t caused anyone a failed edit yet, but I’d be gutted if it ever did. I try to go into my Votes view after each session to double-check, but I just missed one again.

Short of never touching the arrow keys, can anyone recommend a trick for not having this happen? A browser setting or something?

1 Like

What browser and OS are you running?

1 Like

Typically Chromium on Linux, though I’ve also had mishaps on my Mac laptop running Firefox.

1 Like

What you’re describing sounds like it’s at least partially user error. I rely heavily on the arrow keys to scroll up and down pages. If I leave a field highlighted it might trigger something if I don’t manage to click out of it before I try to scroll.
Are you running the mb. POWER VOTE userscript, by any chance?

Oh, it’s completely user error - it’s just that the problem occurs off screen and I don’t always catch it.

I’m not running any user scripts, precisely because I can’t even keep this straight when it’s only me and not browser monkeys too. I even know the use case that triggers it - I’m doing a bunch of yes in a row (as for mass merges) and I try to do down arrow to see the next one - in this scenario PgDn often overshoots and I have to scroll back. That’s the price I’ll have to pay I suppose, otherwise I’m That Guy who votes no and doesn’t say why.

2 Likes

I don’t think this will cause any edits to fail, I can assure you that much.
It might cause a misconfigured vote or two, which is easily fixable if you catch and fix it in time.

The issue is that once the radio buttons have gained focus a keyboard navigation triggers switching between the related radio buttons. In this case up / down arrows seem to behave the same as left / right arrows, with up selecting the previous and down the next radio box. If you click elsewhere on the page after clicking on a radio button it resets the focus and scroll with keyboard works again.

Maybe a small user script like below can help you. You can set this up with your preferred user script manager, e.g. Greasemonkey, Violentmonkey. I only tested this with Violentmonkey in Firefox, though.

// ==UserScript==
// @name        Disable keyboard navigation for edits on musicbrainz.org
// @match       https://musicbrainz.org/search/edits
// @version     1.0
// ==/UserScript==

const SCROLL_DISTANCE = 52

const radioButtons = document.querySelectorAll('input[type=radio]')
for (const button of radioButtons) {
  button.addEventListener('keydown', e => {
    if (e.code == 'ArrowDown' || e.code == 'ArrowUp') {
      e.preventDefault()
      window.scrollBy({
        top: e.code == 'ArrowDown' ? SCROLL_DISTANCE : -SCROLL_DISTANCE,
      })  
    }
  })
}

It prevents the default behavior of selecting the previous / next radio button and triggers a scroll. It does not handle left / right button (so these still can be used to select the radio buttons), but you could add handling these as well of course.

P.S.: Love your username :smiley:

3 Likes

‘Fail’ was the wrong term to use here, since it means something specific. I meant accidentally voting down an edit, which would make me a jerk, and a dumb and clumsy one at that.

1 Like