Skip to content

Commit 9e93af4

Browse files
authored
refactor: replace jQuery with DOM utils for alt and shift key trackers (@MoushufAlam) (monkeytypegame#7266)
### Description Replaces jQuery usage with DOM utils for alt and shift key trackers. Scope intentionally kept small per contributing guidelines. ### Checks - [x] Adding/modifying Typescript code? - [x] I have used `qs`, `qsa` or `qsr` instead of JQuery selectors. - [x] Check if any open issues are related to this PR; if so, be sure to tag them below. - [x] Make sure the PR title follows the Conventional Commits standard. (https://www.conventionalcommits.org for more info) - [x] Make sure to include your GitHub username prefixed with @ inside parentheses at the end of the PR title. <!-- label(optional scope): pull request title (@your_github_username) --> <!-- I know I know they seem boring but please do them, they help us and you will find out it also helps you.--> Related to monkeytypegame#7186 <!-- the issue(s) your PR resolves if any (delete if that is not the case) --> <!-- please also reference any issues and or PRs related to your pull request --> <!-- Also remove it if you are not following any issues. --> <!-- pro tip: you can mention an issue, PR, or discussion on GitHub by referencing its hash number e.g: [monkeytypegame#1234](monkeytypegame#1234) --> <!-- pro tip: you can press . (dot or period) in the code tab of any GitHub repo to get access to GitHub's VS Code web editor Enjoy! :) -->
1 parent d6a6dad commit 9e93af4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

frontend/src/ts/test/alt-tracker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
export let leftState = false;
22
export let rightState = false;
33

4-
$(document).on("keydown", (e) => {
4+
document.addEventListener("keydown", (e: KeyboardEvent) => {
55
if (e.code === "AltLeft") {
66
leftState = true;
77
} else if (e.code === "AltRight") {
88
rightState = true;
99
}
1010
});
1111

12-
$(document).on("keyup", (e) => {
12+
document.addEventListener("keyup", (e: KeyboardEvent) => {
1313
if (e.code === "AltLeft") {
1414
leftState = false;
1515
} else if (e.code === "AltRight") {

frontend/src/ts/test/shift-tracker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as KeyConverter from "../utils/key-converter";
44
export let leftState = false;
55
export let rightState = false;
66

7-
$(document).on("keydown", (e) => {
7+
document.addEventListener("keydown", (e: KeyboardEvent) => {
88
if (e.code === "ShiftLeft") {
99
leftState = true;
1010
rightState = false;
@@ -14,7 +14,7 @@ $(document).on("keydown", (e) => {
1414
}
1515
});
1616

17-
$(document).on("keyup", (e) => {
17+
document.addEventListener("keyup", (e: KeyboardEvent) => {
1818
if (e.code === "ShiftLeft" || e.code === "ShiftRight") {
1919
leftState = false;
2020
rightState = false;

0 commit comments

Comments
 (0)