Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any keyboard layout for Ctrl + V, Z, Y... #755

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
20 changes: 11 additions & 9 deletions src/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1283,8 +1283,10 @@ export class ComfyApp {
}

if (e.type == 'keydown' && !e.repeat) {
const key = e.code

// Ctrl + M mute/unmute
if (e.key === 'm' && (e.metaKey || e.ctrlKey)) {
if (key === 'KeyM' && (e.metaKey || e.ctrlKey)) {
if (this.selected_nodes) {
for (var i in this.selected_nodes) {
if (this.selected_nodes[i].mode === 2) {
Expand All @@ -1299,7 +1301,7 @@ export class ComfyApp {
}

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

// p pin/unpin
if (e.key === 'p') {
if (key === 'KeyP') {
if (this.selected_nodes) {
for (const i in this.selected_nodes) {
const node = this.selected_nodes[i]
Expand All @@ -1325,7 +1327,7 @@ export class ComfyApp {
}

// Alt + C collapse/uncollapse
if (e.key === 'c' && e.altKey) {
if (key === 'KeyC' && e.altKey) {
if (this.selected_nodes) {
for (var i in this.selected_nodes) {
this.selected_nodes[i].collapse()
Expand All @@ -1335,22 +1337,22 @@ export class ComfyApp {
}

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

// Ctrl+V Paste
if (
(e.key === 'v' || e.key == 'V') &&
(key === 'KeyV') &&
(e.metaKey || e.ctrlKey) &&
!e.shiftKey
) {
// Trigger onPaste
return true
}

if (e.key === '+' && e.altKey) {
if ((key === 'NumpadAdd' || key === 'Equal') && e.altKey) {
block_default = true
let scale = this.ds.scale * 1.1
this.ds.changeScale(scale, [
Expand All @@ -1360,9 +1362,9 @@ export class ComfyApp {
this.graph.change()
}

if (e.key === '-' && e.altKey) {
if ((key === 'NumpadSubtract' || key === 'Minus') && e.altKey) {
block_default = true
let scale = (this.ds.scale * 1) / 1.1
let scale = this.ds.scale / 1.1
this.ds.changeScale(scale, [
this.ds.element.width / 2,
this.ds.element.height / 2
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/changeTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ export class ChangeTracker {

async undoRedo(e) {
if (e.ctrlKey || e.metaKey) {
if (e.key === 'y') {
if (e.code === 'KeyY') {
this.updateState(this.redo, this.undo)
return true
} else if (e.key === 'z') {
} else if (e.code === 'KeyZ') {
this.updateState(this.undo, this.redo)
return true
}
Expand Down
Loading