question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Navigating Issues/PRs with keyboard shortcuts

See original GitHub issue
  • Up/down comments - j/k (not up and down arrows for a11y reasons)
  • New comment - n
  • When comment focused:
    • Resolve comment - r
    • Delete comment - d
    • Edit comment - e
    • Reactions?
      • 👍 + (=)
      • 👎 -

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
yakov116commented, Jun 15, 2020

I had fun trying this out.

The j k was beyond me, but I think the code from cycle-lists-with-keyboard-shortcuts should be able to help ou.

import select from 'select-dom';
import * as pageDetect from 'github-url-detection';

import features from '.';

const shortcutKeys = new Set(['e', 'd', 'h']);
const shortcutClass: Record<string, string> = {
	e: '.rgh-edit-comment, [aria-label="Edit comment"]',
	d: '[aria-label="Delete comment"]',
	h: '[aria-label="Hide comment"]'
};

function triggerShortcut(shortcut: string) {
	const selectedComment = select(location.hash)!;
	select<HTMLButtonElement>(shortcutClass[shortcut], selectedComment)?.click();
}

function init(): void {
	document.addEventListener('keypress', event => {
		if (!shortcutKeys.has(event.key) || event.target instanceof HTMLTextAreaElement || event.target instanceof HTMLInputElement) {
			return;
		}
		event.preventDefault();
		if (location.hash) {
			triggerShortcut(event.key);
		}
	});
}

void features.add({
	id: __filebasename,
	description: '',
	screenshot: false
}, {
	include: [
		pageDetect.hasComments
	],
	repeatOnAjax: false,
	init
});
1reaction
fregantecommented, Jun 16, 2020

Looks reasonable. Let’s see a PR

Read more comments on GitHub >

github_iconTop Results From Across the Web

Navigating Issues/PRs with keyboard shortcuts #1270 - GitHub
Navigating Issues/PRs with keyboard shortcuts #1270 ... Extends to comments, files, dashboard travelist/github-shortcuts#1.
Read more >
Keyboard shortcuts in Windows - Microsoft Support
Learn how to navigate Windows using keyboard shortcuts. Explore a full list of taskbar, command prompt, and general Windows shortcuts.
Read more >
How to navigate the GitHub web without a mouse
Run commands using CTRL + Shift + K (for Windows/Linux), or ⌘ + Shift + K (macOS); Switch to command mode by using...
Read more >
Keyboard shortcuts for navigation—ArcGIS Pro | Documentation
Keyboard shortcut keys are designed to assist with the navigation experience so you spend less time changing tools. Some shortcuts are available at...
Read more >
cfg maker
6 cfg letöltés » low profile keyboard. cfg file to delete the #4 ... Download APKPure APP to get the latest update of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found