Skip to content

Instantly share code, notes, and snippets.

@dkniffin
Last active May 1, 2022 13:15
Show Gist options
  • Save dkniffin/26514271160571386b3a17e55fbcdd77 to your computer and use it in GitHub Desktop.
Save dkniffin/26514271160571386b3a17e55fbcdd77 to your computer and use it in GitHub Desktop.
Adds hotkeys for FamilySearch's Review Names tool (for the 1950 census)
const matchButton = document.querySelector("[data-testid='Match']").closest("button")
const editButton = document.querySelector("[data-testid='Edit']").closest("button")
const unsureButton = document.querySelector("[data-testid='Unsure']").closest("button")
const notAPersonButton = document.querySelector("[data-testid='Not A Person']").closest("button")
const transcriptionErrorButton = document.querySelector("[data-testid='Transcription Error']").closest("button")
document.addEventListener("keydown", (e) => {
const nameField = document.querySelector("input[name='nameField']")
if (nameField == document.activeElement) { return }
switch (e.code) {
case "KeyM":
e.preventDefault()
matchButton.click()
break
case "KeyE":
e.preventDefault()
editButton.click()
break
case "KeyU":
e.preventDefault()
unsureButton.click()
break
case "KeyN":
e.preventDefault()
notAPersonButton.click()
break
}
})
@dkniffin
Copy link
Author

dkniffin commented May 1, 2022

NOTE: this is not quite working right. There's an issue with it when hitting enter to submit the edit. That doesn't seem to unfocus the field.

Clicking any of the hotkeys while not focused on the edit field will trigger the corresponding action

M = Match
E = Edit (focus on the name field; you can hit enter to go to the next line and unfocus the edit field)
U = Unsure
N = Not a Person

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment