Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

Fix cell movement shortcuts on non-Mac keyboards (#5759)

Trevor Manz36bda832fc4c
diff --git a/frontend/src/components/editor/navigation/__tests__/navigation.test.ts b/frontend/src/components/editor/navigation/__tests__/navigation.test.ts
index 97baf95cd7..ff103a4fc5 100644
--- a/frontend/src/components/editor/navigation/__tests__/navigation.test.ts
+++ b/frontend/src/components/editor/navigation/__tests__/navigation.test.ts
@@ -645,6 +645,7 @@ describe("useCellNavigationProps", () => {
const mockEvent = Mocks.keyboardEvent({
key: "9",
+ code: "Digit9",
ctrlKey: true,
shiftKey: true,
});
@@ -667,6 +668,7 @@ describe("useCellNavigationProps", () => {
const mockEvent = Mocks.keyboardEvent({
key: "9",
+ code: "Digit9",
ctrlKey: true,
shiftKey: true,
});
@@ -686,6 +688,7 @@ describe("useCellNavigationProps", () => {
const mockEvent = Mocks.keyboardEvent({
key: "0",
+ code: "Digit0",
ctrlKey: true,
shiftKey: true,
});
@@ -761,6 +764,7 @@ describe("useCellNavigationProps", () => {
const mockEvent = Mocks.keyboardEvent({
key: "9",
+ code: "Digit9",
ctrlKey: true,
shiftKey: true,
});
@@ -795,6 +799,7 @@ describe("useCellNavigationProps", () => {
const mockEvent = Mocks.keyboardEvent({
key: "0",
+ code: "Digit0",
ctrlKey: true,
shiftKey: true,
});
@@ -830,6 +835,7 @@ describe("useCellNavigationProps", () => {
const mockEvent = Mocks.keyboardEvent({
key: "1",
+ code: "Digit1",
ctrlKey: true,
shiftKey: true,
});
@@ -862,6 +868,7 @@ describe("useCellNavigationProps", () => {
const mockEvent = Mocks.keyboardEvent({
key: "2",
+ code: "Digit2",
ctrlKey: true,
shiftKey: true,
});
@@ -1365,6 +1372,7 @@ describe("useCellNavigationProps", () => {
const mockEvent = Mocks.keyboardEvent({
key: "7",
+ code: "Digit7",
ctrlKey: true,
shiftKey: true,
});
@@ -1389,6 +1397,7 @@ describe("useCellNavigationProps", () => {
const mockEvent = Mocks.keyboardEvent({
key: "8",
+ code: "Digit8",
ctrlKey: true,
shiftKey: true,
});
@@ -1411,6 +1420,7 @@ describe("useCellNavigationProps", () => {
const mockEvent = Mocks.keyboardEvent({
key: "7",
+ code: "Digit7",
ctrlKey: true,
shiftKey: true,
});
@@ -1430,6 +1440,7 @@ describe("useCellNavigationProps", () => {
const mockEvent = Mocks.keyboardEvent({
key: "8",
+ code: "Digit8",
ctrlKey: true,
shiftKey: true,
});
@@ -1459,6 +1470,7 @@ describe("useCellNavigationProps", () => {
const mockEvent = Mocks.keyboardEvent({
key: "7",
+ code: "Digit7",
ctrlKey: true,
shiftKey: true,
});
diff --git a/frontend/src/core/hotkeys/shortcuts.ts b/frontend/src/core/hotkeys/shortcuts.ts
index 6b9ceecd53..c911373c73 100644
--- a/frontend/src/core/hotkeys/shortcuts.ts
+++ b/frontend/src/core/hotkeys/shortcuts.ts
@@ -50,7 +50,17 @@ function areKeysPressed(keys: string[], e: IKeyboardEvent): boolean {
satisfied &&= e.code === "Space";
break;
default:
- satisfied &&= e.key.toLowerCase() === key;
+ // Handle digit keys specially when shift is pressed
+ // Shift+7 produces different characters across keyboards/platforms:
+ // - US keyboards: "&"
+ // - Some layouts: "7"
+ // Using e.code (physical key) instead of e.key (produced character)
+ // eslint-disable-next-line unicorn/prefer-ternary
+ if (/^\d$/.test(key) && e.shiftKey) {
+ satisfied &&= e.code === `Digit${key}`;
+ } else {
+ satisfied &&= e.key.toLowerCase() === key;
+ }
break;
}