Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions src/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,7 @@ export class ComfyApp {
#addProcessKeyHandler() {
const origProcessKey = LGraphCanvas.prototype.processKey
LGraphCanvas.prototype.processKey = function (e: KeyboardEvent) {
if (!this.graph) {
return
}

var block_default = false
if (!this.graph) return

if (e.target instanceof Element && e.target.localName == 'input') {
return
Expand All @@ -521,15 +517,19 @@ export class ComfyApp {
const keyCombo = KeyComboImpl.fromEvent(e)
const keybindingStore = useKeybindingStore()
const keybinding = keybindingStore.getKeybinding(keyCombo)

if (keybinding && keybinding.targetElementId === 'graph-canvas') {
useCommandStore().execute(keybinding.commandId)
block_default = true

this.graph.change()
e.preventDefault()
e.stopImmediatePropagation()
return
}

// Ctrl+C Copy
if (e.key === 'c' && (e.metaKey || e.ctrlKey)) {
// Trigger onCopy
return true
return
}

// Ctrl+V Paste
Expand All @@ -538,19 +538,10 @@ export class ComfyApp {
(e.metaKey || e.ctrlKey) &&
!e.shiftKey
) {
// Trigger onPaste
return true
return
}
}

this.graph.change()

if (block_default) {
e.preventDefault()
e.stopImmediatePropagation()
return false
}

// Fall through to Litegraph defaults
// @ts-expect-error fixme ts strict error
return origProcessKey.apply(this, arguments)
Expand Down