-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
45 lines (40 loc) · 987 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
(() => {
let isTabPressed = false;
const focusTask = () => {
// Try new style task row at first.
const cell =
document.querySelector(".SpreadsheetCell--isHighlighted") ||
document.querySelector(".SpreadsheetCell");
if (cell) {
cell.focus();
return;
}
// Prevent focusing back to the head.
const focused = document.querySelector(".ItemRow--focused");
if (focused) return;
// Try old style task row then.
const row =
document.querySelector(".ItemRow--highlighted") ||
document.querySelector(".ItemRow");
if (row) {
row.click();
}
};
document.addEventListener("keydown", (e) => {
switch (e.key) {
case "Tab":
isTabPressed = true;
break;
case "e":
isTabPressed && focusTask();
break;
}
});
document.addEventListener("keyup", (e) => {
switch (e.key) {
case "Tab":
isTabPressed = false;
break;
}
});
})();