"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "helpers/keybindings.ts" between
hoppscotch-2.0.0.tar.gz and hoppscotch-2.1.0.tar.gz

About: Hoppscotch is a light-weight, web based API development suite.

keybindings.ts  (hoppscotch-2.0.0):keybindings.ts  (hoppscotch-2.1.0)
skipping to change at line 60 skipping to change at line 60
"alt-x": "request.method.delete", "alt-x": "request.method.delete",
"ctrl-k": "flyouts.keybinds.toggle", "ctrl-k": "flyouts.keybinds.toggle",
"/": "modals.search.toggle", "/": "modals.search.toggle",
"?": "modals.support.toggle", "?": "modals.support.toggle",
"ctrl-m": "modals.share.toggle", "ctrl-m": "modals.share.toggle",
"alt-r": "navigation.jump.rest", "alt-r": "navigation.jump.rest",
"alt-q": "navigation.jump.graphql", "alt-q": "navigation.jump.graphql",
"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",
} }
/** /**
* A composable that hooks to the caller component's * A composable that hooks to the caller component's
* lifecycle and hooks to the keyboard events to fire * lifecycle and hooks to the keyboard events to fire
* the appropriate actions based on keybindings * the appropriate actions based on keybindings
*/ */
export function hookKeybindingsListener() { export function hookKeybindingsListener() {
onMounted(() => { onMounted(() => {
document.addEventListener("keydown", handleKeyDown) document.addEventListener("keydown", handleKeyDown)
skipping to change at line 94 skipping to change at line 92
if (!binding) return if (!binding) return
const boundAction = bindings[binding] const boundAction = bindings[binding]
if (!boundAction) return if (!boundAction) return
ev.preventDefault() ev.preventDefault()
invokeAction(boundAction) invokeAction(boundAction)
} }
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)
const target = ev.target // We will always have a non-modifier key
if (!modifierKey && !(isDOMElement(target) && isTypableElement(target))) {
// Check if we are having singulars instead
const key = getPressedKey(ev)
if (!key) return null
else return `${key}` as ShortcutKey
}
const key = getPressedKey(ev) const key = getPressedKey(ev)
if (!key) return null if (!key) return null
return `${modifierKey}-${key}` as ShortcutKey // All key combos backed by modifiers are valid shortcuts (whether currently t
yping or not)
if (modifierKey) return `${modifierKey}-${key}`
const target = ev.target
// no modifier key here then we do not do anything while on input
if (isDOMElement(target) && isTypableElement(target)) return null
// single key while not input
return `${key}`
} }
function getPressedKey(ev: KeyboardEvent): Key | null { function getPressedKey(ev: KeyboardEvent): Key | null {
const val = ev.key.toLowerCase() const val = ev.key.toLowerCase()
// Check arrow keys // Check arrow keys
if (val === "arrowup") return "up" if (val === "arrowup") return "up"
else if (val === "arrowdown") return "down" else if (val === "arrowdown") return "down"
else if (val === "arrowleft") return "left" else if (val === "arrowleft") return "left"
else if (val === "arrowright") return "right" else if (val === "arrowright") return "right"
// Check letter keys // Check letter keys
if (val.length === 1 && val.toUpperCase() !== val.toLowerCase()) if (val.length === 1 && val.toUpperCase() !== val.toLowerCase())
return val as Key return val as Key
 End of changes. 5 change blocks. 
15 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)