fix: single character shortcuts not working
This commit is contained in:
@@ -27,8 +27,6 @@ export type HoppAction =
|
|||||||
| "navigation.jump.realtime" // Jump to realtime page
|
| "navigation.jump.realtime" // Jump to realtime page
|
||||||
| "navigation.jump.documentation" // Jump to documentation page
|
| "navigation.jump.documentation" // Jump to documentation page
|
||||||
| "navigation.jump.settings" // Jump to settings page
|
| "navigation.jump.settings" // Jump to settings page
|
||||||
| "navigation.jump.back" // Jump to previous page
|
|
||||||
| "navigation.jump.forward" // Jump to next page
|
|
||||||
|
|
||||||
type BoundActionList = {
|
type BoundActionList = {
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
|||||||
@@ -57,8 +57,6 @@ export const bindings: {
|
|||||||
"alt-w": "navigation.jump.realtime",
|
"alt-w": "navigation.jump.realtime",
|
||||||
"alt-d": "navigation.jump.documentation",
|
"alt-d": "navigation.jump.documentation",
|
||||||
"alt-s": "navigation.jump.settings",
|
"alt-s": "navigation.jump.settings",
|
||||||
"ctrl-left": "navigation.jump.back",
|
|
||||||
"ctrl-right": "navigation.jump.forward",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,22 +89,23 @@ function handleKeyDown(ev: KeyboardEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function generateKeybindingString(ev: KeyboardEvent): ShortcutKey | null {
|
function generateKeybindingString(ev: KeyboardEvent): ShortcutKey | null {
|
||||||
// All our keybinds need to have one modifier pressed atleast
|
// We may or may not have a modifier key
|
||||||
const modifierKey = getActiveModifier(ev)
|
const modifierKey = getActiveModifier(ev)
|
||||||
|
|
||||||
|
// We will always have a non-modifier key
|
||||||
|
const key = getPressedKey(ev)
|
||||||
|
if (!key) return null
|
||||||
|
|
||||||
|
// All key combos backed by modifiers are valid shortcuts (whether currently typing or not)
|
||||||
|
if (modifierKey) return `${modifierKey}-${key}`
|
||||||
|
|
||||||
const target = ev.target
|
const target = ev.target
|
||||||
// override default behaviour if element is typable
|
|
||||||
if (modifierKey && isDOMElement(target) && isTypableElement(target)) {
|
|
||||||
const key = getPressedKey(ev)
|
|
||||||
|
|
||||||
if (!key) return null
|
// no modifier key here then we do not do anything while on input
|
||||||
else return `${key}` as ShortcutKey
|
if (isDOMElement(target) && isTypableElement(target)) return null
|
||||||
}
|
|
||||||
|
|
||||||
const key = getPressedKey(ev)
|
// single key while not input
|
||||||
if (!key) return null
|
return `${key}`
|
||||||
|
|
||||||
return `${modifierKey}-${key}` as ShortcutKey
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPressedKey(ev: KeyboardEvent): Key | null {
|
function getPressedKey(ev: KeyboardEvent): Key | null {
|
||||||
|
|||||||
@@ -136,18 +136,6 @@ export const spotlight = [
|
|||||||
{
|
{
|
||||||
section: "shortcut.navigation.title",
|
section: "shortcut.navigation.title",
|
||||||
shortcuts: [
|
shortcuts: [
|
||||||
{
|
|
||||||
keys: [getPlatformSpecialKey(), "←"],
|
|
||||||
label: "shortcut.navigation.back",
|
|
||||||
action: "navigation.jump.back",
|
|
||||||
icon: "arrow-right",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
keys: [getPlatformSpecialKey(), "→"],
|
|
||||||
label: "shortcut.navigation.forward",
|
|
||||||
action: "navigation.jump.forward",
|
|
||||||
icon: "arrow-right",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
keys: [getPlatformAlternateKey(), "R"],
|
keys: [getPlatformAlternateKey(), "R"],
|
||||||
label: "shortcut.navigation.rest",
|
label: "shortcut.navigation.rest",
|
||||||
@@ -223,20 +211,6 @@ export const fuse = [
|
|||||||
icon: "zap",
|
icon: "zap",
|
||||||
tags: ["keyboard", "shortcuts"],
|
tags: ["keyboard", "shortcuts"],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
keys: [getPlatformSpecialKey(), "←"],
|
|
||||||
label: "shortcut.navigation.back",
|
|
||||||
action: "navigation.jump.back",
|
|
||||||
icon: "arrow-right",
|
|
||||||
tags: ["back", "jump", "page", "navigation", "go"],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
keys: [getPlatformSpecialKey(), "→"],
|
|
||||||
label: "shortcut.navigation.forward",
|
|
||||||
action: "navigation.jump.forward",
|
|
||||||
icon: "arrow-right",
|
|
||||||
tags: ["forward", "jump", "next", "forward", "page", "navigation", "go"],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
keys: [getPlatformAlternateKey(), "R"],
|
keys: [getPlatformAlternateKey(), "R"],
|
||||||
label: "shortcut.navigation.rest",
|
label: "shortcut.navigation.rest",
|
||||||
|
|||||||
@@ -125,12 +125,6 @@ function defineJumpActions() {
|
|||||||
defineActionHandler("navigation.jump.settings", () => {
|
defineActionHandler("navigation.jump.settings", () => {
|
||||||
router.push({ path: localePath("/settings") })
|
router.push({ path: localePath("/settings") })
|
||||||
})
|
})
|
||||||
defineActionHandler("navigation.jump.back", () => {
|
|
||||||
router.go(-1)
|
|
||||||
})
|
|
||||||
defineActionHandler("navigation.jump.forward", () => {
|
|
||||||
router.go(1)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
|||||||
Reference in New Issue
Block a user