Skip to content

Commit ee5057c

Browse files
authored
Any keyboard layout for Ctrl + V, Z, Y...
`if` conditioning changed for better support any keyboard layout for shortcuts
1 parent 61ee43a commit ee5057c

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/scripts/app.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,8 +1283,10 @@ export class ComfyApp {
12831283
}
12841284

12851285
if (e.type == 'keydown' && !e.repeat) {
1286+
const key = e.code
1287+
12861288
// Ctrl + M mute/unmute
1287-
if (e.key === 'm' && (e.metaKey || e.ctrlKey)) {
1289+
if (key === 'KeyM' && (e.metaKey || e.ctrlKey)) {
12881290
if (this.selected_nodes) {
12891291
for (var i in this.selected_nodes) {
12901292
if (this.selected_nodes[i].mode === 2) {
@@ -1299,7 +1301,7 @@ export class ComfyApp {
12991301
}
13001302

13011303
// Ctrl + B bypass
1302-
if (e.key === 'b' && (e.metaKey || e.ctrlKey)) {
1304+
if (key === 'KeyB' && (e.metaKey || e.ctrlKey)) {
13031305
if (this.selected_nodes) {
13041306
for (var i in this.selected_nodes) {
13051307
if (this.selected_nodes[i].mode === 4) {
@@ -1314,7 +1316,7 @@ export class ComfyApp {
13141316
}
13151317

13161318
// p pin/unpin
1317-
if (e.key === 'p') {
1319+
if (key === 'KeyP') {
13181320
if (this.selected_nodes) {
13191321
for (const i in this.selected_nodes) {
13201322
const node = this.selected_nodes[i]
@@ -1325,7 +1327,7 @@ export class ComfyApp {
13251327
}
13261328

13271329
// Alt + C collapse/uncollapse
1328-
if (e.key === 'c' && e.altKey) {
1330+
if (key === 'KeyC' && e.altKey) {
13291331
if (this.selected_nodes) {
13301332
for (var i in this.selected_nodes) {
13311333
this.selected_nodes[i].collapse()
@@ -1335,22 +1337,22 @@ export class ComfyApp {
13351337
}
13361338

13371339
// Ctrl+C Copy
1338-
if (e.key === 'c' && (e.metaKey || e.ctrlKey)) {
1340+
if (key === 'KeyC' && (e.metaKey || e.ctrlKey)) {
13391341
// Trigger onCopy
13401342
return true
13411343
}
13421344

13431345
// Ctrl+V Paste
13441346
if (
1345-
(e.key === 'v' || e.key == 'V') &&
1347+
(key === 'KeyV') &&
13461348
(e.metaKey || e.ctrlKey) &&
13471349
!e.shiftKey
13481350
) {
13491351
// Trigger onPaste
13501352
return true
13511353
}
13521354

1353-
if (e.key === '+' && e.altKey) {
1355+
if ((key === 'NumpadAdd' || key === 'Equal') && e.altKey) {
13541356
block_default = true
13551357
let scale = this.ds.scale * 1.1
13561358
this.ds.changeScale(scale, [
@@ -1360,9 +1362,9 @@ export class ComfyApp {
13601362
this.graph.change()
13611363
}
13621364

1363-
if (e.key === '-' && e.altKey) {
1365+
if ((key === 'NumpadSubtract' || key === 'Minus') && e.altKey) {
13641366
block_default = true
1365-
let scale = (this.ds.scale * 1) / 1.1
1367+
let scale = this.ds.scale / 1.1
13661368
this.ds.changeScale(scale, [
13671369
this.ds.element.width / 2,
13681370
this.ds.element.height / 2

src/scripts/changeTracker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ export class ChangeTracker {
8282

8383
async undoRedo(e) {
8484
if (e.ctrlKey || e.metaKey) {
85-
if (e.key === 'y') {
85+
if (e.code === 'KeyY') {
8686
this.updateState(this.redo, this.undo)
8787
return true
88-
} else if (e.key === 'z') {
88+
} else if (e.code === 'KeyZ') {
8989
this.updateState(this.undo, this.redo)
9090
return true
9191
}

0 commit comments

Comments
 (0)