mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-02-17 02:22:23 +01:00
Fix some key not working
This commit is contained in:
@ -48,7 +48,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
|||||||
const terminalInput = useRef<HTMLInputElement>(null);
|
const terminalInput = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
const [value, setValue] = useState(command);
|
const [value, setValue] = useState(command);
|
||||||
const [postUpdateValue, setPostUpdateValue] = useState<{postUpdate: () => void} | null>()
|
const [postUpdateValue, setPostUpdateValue] = useState<{ postUpdate: () => void } | null>();
|
||||||
const [possibilities, setPossibilities] = useState<string[]>([]);
|
const [possibilities, setPossibilities] = useState<string[]>([]);
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
@ -65,14 +65,14 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
|||||||
postUpdateValue.postUpdate();
|
postUpdateValue.postUpdate();
|
||||||
setPostUpdateValue(null);
|
setPostUpdateValue(null);
|
||||||
}
|
}
|
||||||
}, [postUpdateValue])
|
}, [postUpdateValue]);
|
||||||
|
|
||||||
function saveValue(newValue: string, postUpdate?: () => void): void {
|
function saveValue(newValue: string, postUpdate?: () => void): void {
|
||||||
command = newValue;
|
command = newValue;
|
||||||
setValue(newValue);
|
setValue(newValue);
|
||||||
|
|
||||||
if (postUpdate) {
|
if (postUpdate) {
|
||||||
setPostUpdateValue({postUpdate});
|
setPostUpdateValue({ postUpdate });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
|||||||
// Move cursor to correct location
|
// Move cursor to correct location
|
||||||
// foo bar |baz bum --> foo |baz bum
|
// foo bar |baz bum --> foo |baz bum
|
||||||
const ref = terminalInput.current;
|
const ref = terminalInput.current;
|
||||||
ref?.setSelectionRange(delStart+1, delStart+1);
|
ref?.setSelectionRange(delStart + 1, delStart + 1);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
|||||||
// Move cursor to correct location
|
// Move cursor to correct location
|
||||||
// foo bar |baz bum --> foo bar |bum
|
// foo bar |baz bum --> foo bar |bum
|
||||||
const ref = terminalInput.current;
|
const ref = terminalInput.current;
|
||||||
ref?.setSelectionRange(start, start)
|
ref?.setSelectionRange(start, start);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function keyDown(this: Document, event: KeyboardEvent): void {
|
function keyDown(this: Document, event: KeyboardEvent): void {
|
||||||
if (terminal.contractOpen) return;
|
if (terminal.contractOpen) return;
|
||||||
if (terminal.action !== null && event.key === KEY.c && event.ctrlKey) {
|
if (terminal.action !== null && event.key === KEY.C && event.ctrlKey) {
|
||||||
terminal.finishAction(router, player, true);
|
terminal.finishAction(router, player, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Autocomplete
|
// Autocomplete
|
||||||
if (event.key === KEY.Tab && value !== "") {
|
if (event.key === KEY.TAB && value !== "") {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
let copy = value;
|
let copy = value;
|
||||||
|
@ -1,55 +1,53 @@
|
|||||||
import { IMap } from "../../types";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keyboard key codes
|
* Keyboard key codes
|
||||||
*/
|
*/
|
||||||
export const KEY: IMap<string> = {
|
export enum KEY {
|
||||||
//SHIFT: 16, // Check by `&& event.shiftKey`
|
//SHIFT: 16, // Check by `&& event.shiftKey`
|
||||||
//CTRL: 17, // Check by `&& event.ctrlKey`
|
//CTRL: 17, // Check by `&& event.ctrlKey`
|
||||||
//ALT: 18, // Check by `&& event.altKey`
|
//ALT: 18, // Check by `&& event.altKey`
|
||||||
ENTER: "Enter",
|
ENTER = "Enter",
|
||||||
ESC: "Escape",
|
ESC = "Escape",
|
||||||
TAB: "Tab",
|
TAB = "Tab",
|
||||||
UPARROW: "ArrowUp",
|
UPARROW = "ArrowUp",
|
||||||
DOWNARROW: "ArrowDown",
|
DOWNARROW = "ArrowDown",
|
||||||
LEFTARROW: "ArrowLeft",
|
LEFTARROW = "ArrowLeft",
|
||||||
RIGHTARROW: "ArrowRight",
|
RIGHTARROW = "ArrowRight",
|
||||||
|
|
||||||
"0": "0",
|
k0 = "0",
|
||||||
"1": "1",
|
k1 = "1",
|
||||||
"2": "2",
|
k2 = "2",
|
||||||
"3": "3",
|
k3 = "3",
|
||||||
"4": "4",
|
k4 = "4",
|
||||||
"5": "5",
|
k5 = "5",
|
||||||
"6": "6",
|
k6 = "6",
|
||||||
"7": "7",
|
k7 = "7",
|
||||||
"8": "8",
|
k8 = "8",
|
||||||
"9": "9",
|
k9 = "9",
|
||||||
|
|
||||||
A: "a",
|
A = "a",
|
||||||
B: "b",
|
B = "b",
|
||||||
C: "c",
|
C = "c",
|
||||||
D: "d",
|
D = "d",
|
||||||
E: "e",
|
E = "e",
|
||||||
F: "f",
|
F = "f",
|
||||||
G: "g",
|
G = "g",
|
||||||
H: "h",
|
H = "h",
|
||||||
I: "i",
|
I = "i",
|
||||||
J: "j",
|
J = "j",
|
||||||
K: "k",
|
K = "k",
|
||||||
L: "l",
|
L = "l",
|
||||||
M: "m",
|
M = "m",
|
||||||
N: "n",
|
N = "n",
|
||||||
O: "o",
|
O = "o",
|
||||||
P: "p",
|
P = "p",
|
||||||
Q: "q",
|
Q = "q",
|
||||||
R: "r",
|
R = "r",
|
||||||
S: "s",
|
S = "s",
|
||||||
T: "t",
|
T = "t",
|
||||||
U: "u",
|
U = "u",
|
||||||
V: "v",
|
V = "v",
|
||||||
W: "w",
|
W = "w",
|
||||||
X: "x",
|
X = "x",
|
||||||
Y: "y",
|
Y = "y",
|
||||||
Z: "z",
|
Z = "z",
|
||||||
};
|
}
|
||||||
|
Reference in New Issue
Block a user