fix: replaced KeyboardEvent.code with KeyboardEvent.key for all letters (#5523)
* fix: Replaced KeyboardEvent.code with KeyboardEvent.key for all letters * fix: reverted all keybindings that included alt to use code instead of keys Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
This commit is contained in:
parent
55110bf1b8
commit
79bd3b8cda
@ -36,7 +36,7 @@ export const actionCut = register({
|
||||
return actionDeleteSelected.perform(elements, appState);
|
||||
},
|
||||
contextItemLabel: "labels.cut",
|
||||
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.code === CODES.X,
|
||||
keyTest: (event) => event[KEYS.CTRL_OR_CMD] && event.key === KEYS.X,
|
||||
});
|
||||
|
||||
export const actionCopyAsSvg = register({
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { CODES, KEYS } from "../keys";
|
||||
import { KEYS } from "../keys";
|
||||
import { t } from "../i18n";
|
||||
import { arrayToMap, getShortcutKey } from "../utils";
|
||||
import { register } from "./register";
|
||||
@ -132,7 +132,7 @@ export const actionGroup = register({
|
||||
contextItemPredicate: (elements, appState) =>
|
||||
enableActionGroup(elements, appState),
|
||||
keyTest: (event) =>
|
||||
!event.shiftKey && event[KEYS.CTRL_OR_CMD] && event.code === CODES.G,
|
||||
!event.shiftKey && event[KEYS.CTRL_OR_CMD] && event.key === KEYS.G,
|
||||
PanelComponent: ({ elements, appState, updateData }) => (
|
||||
<ToolButton
|
||||
hidden={!enableActionGroup(elements, appState)}
|
||||
@ -189,7 +189,7 @@ export const actionUngroup = register({
|
||||
};
|
||||
},
|
||||
keyTest: (event) =>
|
||||
event.shiftKey && event[KEYS.CTRL_OR_CMD] && event.code === CODES.G,
|
||||
event.shiftKey && event[KEYS.CTRL_OR_CMD] && event.key === KEYS.G,
|
||||
contextItemLabel: "labels.ungroup",
|
||||
contextItemPredicate: (elements, appState) =>
|
||||
getSelectedGroupIds(appState).length > 0,
|
||||
|
@ -4,7 +4,7 @@ import { t } from "../i18n";
|
||||
import { showSelectedShapeActions, getNonDeletedElements } from "../element";
|
||||
import { register } from "./register";
|
||||
import { allowFullScreen, exitFullScreen, isFullScreen } from "../utils";
|
||||
import { CODES, KEYS } from "../keys";
|
||||
import { KEYS } from "../keys";
|
||||
import { HelpIcon } from "../components/HelpIcon";
|
||||
|
||||
export const actionToggleCanvasMenu = register({
|
||||
@ -67,7 +67,7 @@ export const actionFullScreen = register({
|
||||
commitToHistory: false,
|
||||
};
|
||||
},
|
||||
keyTest: (event) => event.code === CODES.F && !event[KEYS.CTRL_OR_CMD],
|
||||
keyTest: (event) => event.key === KEYS.F && !event[KEYS.CTRL_OR_CMD],
|
||||
});
|
||||
|
||||
export const actionShortcuts = register({
|
||||
|
@ -18,11 +18,8 @@ export const CODES = {
|
||||
SLASH: "Slash",
|
||||
C: "KeyC",
|
||||
D: "KeyD",
|
||||
G: "KeyG",
|
||||
F: "KeyF",
|
||||
H: "KeyH",
|
||||
V: "KeyV",
|
||||
X: "KeyX",
|
||||
Z: "KeyZ",
|
||||
R: "KeyR",
|
||||
} as const;
|
||||
@ -47,9 +44,12 @@ export const KEYS = {
|
||||
COMMA: ",",
|
||||
|
||||
A: "a",
|
||||
C: "c",
|
||||
D: "d",
|
||||
E: "e",
|
||||
F: "f",
|
||||
G: "g",
|
||||
H: "h",
|
||||
I: "i",
|
||||
L: "l",
|
||||
O: "o",
|
||||
|
@ -14,7 +14,7 @@ import ExcalidrawApp from "../excalidraw-app";
|
||||
import * as Renderer from "../renderer/renderScene";
|
||||
import { reseed } from "../random";
|
||||
import { UI, Pointer, Keyboard } from "./helpers/ui";
|
||||
import { CODES } from "../keys";
|
||||
import { KEYS } from "../keys";
|
||||
import { ShortcutName } from "../actions/shortcuts";
|
||||
import { copiedStyles } from "../actions/actionStyles";
|
||||
import { API } from "./helpers/api";
|
||||
@ -240,7 +240,7 @@ describe("contextMenu element", () => {
|
||||
});
|
||||
|
||||
Keyboard.withModifierKeys({ ctrl: true }, () => {
|
||||
Keyboard.codePress(CODES.G);
|
||||
Keyboard.keyPress(KEYS.G);
|
||||
});
|
||||
|
||||
fireEvent.contextMenu(GlobalTestState.canvas, {
|
||||
@ -537,7 +537,7 @@ describe("contextMenu element", () => {
|
||||
});
|
||||
|
||||
Keyboard.withModifierKeys({ ctrl: true }, () => {
|
||||
Keyboard.codePress(CODES.G);
|
||||
Keyboard.keyPress(KEYS.G);
|
||||
});
|
||||
|
||||
fireEvent.contextMenu(GlobalTestState.canvas, {
|
||||
|
@ -3,7 +3,7 @@ import {
|
||||
ExcalidrawLinearElement,
|
||||
ExcalidrawTextElement,
|
||||
} from "../../element/types";
|
||||
import { CODES } from "../../keys";
|
||||
import { KEYS } from "../../keys";
|
||||
import { ToolName } from "../queries/toolQueries";
|
||||
import { fireEvent, GlobalTestState } from "../test-utils";
|
||||
import { mutateElement } from "../../element/mutateElement";
|
||||
@ -314,7 +314,7 @@ export class UI {
|
||||
static group(elements: ExcalidrawElement[]) {
|
||||
mouse.select(elements);
|
||||
Keyboard.withModifierKeys({ ctrl: true }, () => {
|
||||
Keyboard.codePress(CODES.G);
|
||||
Keyboard.keyPress(KEYS.G);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -485,7 +485,7 @@ describe("regression tests", () => {
|
||||
}
|
||||
|
||||
Keyboard.withModifierKeys({ ctrl: true }, () => {
|
||||
Keyboard.codePress(CODES.G);
|
||||
Keyboard.keyPress(KEYS.G);
|
||||
});
|
||||
|
||||
for (const element of h.elements) {
|
||||
@ -524,7 +524,7 @@ describe("regression tests", () => {
|
||||
|
||||
Keyboard.withModifierKeys({ ctrl: true }, () => {
|
||||
Keyboard.keyPress(KEYS.A);
|
||||
Keyboard.codePress(CODES.G);
|
||||
Keyboard.keyPress(KEYS.G);
|
||||
});
|
||||
|
||||
expect(API.getSelectedElements().length).toBe(3);
|
||||
@ -561,7 +561,7 @@ describe("regression tests", () => {
|
||||
mouse.click();
|
||||
});
|
||||
Keyboard.withModifierKeys({ ctrl: true }, () => {
|
||||
Keyboard.codePress(CODES.G);
|
||||
Keyboard.keyPress(KEYS.G);
|
||||
});
|
||||
|
||||
expect(h.elements.map((element) => element.id)).toEqual([
|
||||
@ -578,7 +578,7 @@ describe("regression tests", () => {
|
||||
|
||||
Keyboard.withModifierKeys({ ctrl: true }, () => {
|
||||
Keyboard.keyPress(KEYS.A);
|
||||
Keyboard.codePress(CODES.G);
|
||||
Keyboard.keyPress(KEYS.G);
|
||||
});
|
||||
|
||||
mouse.doubleClickOn(rectC);
|
||||
@ -586,7 +586,7 @@ describe("regression tests", () => {
|
||||
mouse.clickOn(rectA);
|
||||
});
|
||||
Keyboard.withModifierKeys({ ctrl: true }, () => {
|
||||
Keyboard.codePress(CODES.G);
|
||||
Keyboard.keyPress(KEYS.G);
|
||||
});
|
||||
|
||||
expect(rectC.groupIds.length).toBe(2);
|
||||
@ -996,7 +996,7 @@ describe("regression tests", () => {
|
||||
|
||||
Keyboard.withModifierKeys({ ctrl: true }, () => {
|
||||
Keyboard.keyPress(KEYS.A);
|
||||
Keyboard.codePress(CODES.G);
|
||||
Keyboard.keyPress(KEYS.G);
|
||||
});
|
||||
|
||||
const selectedGroupIds_prev = h.state.selectedGroupIds;
|
||||
@ -1110,7 +1110,7 @@ it(
|
||||
|
||||
// Create group with first and third rectangle
|
||||
Keyboard.withModifierKeys({ ctrl: true }, () => {
|
||||
Keyboard.codePress(CODES.G);
|
||||
Keyboard.keyPress(KEYS.G);
|
||||
});
|
||||
|
||||
expect(API.getSelectedElements().length).toBe(2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user