mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-23 22:52:29 +01:00
Changed .keyCode to .key for files in "src"
This commit is contained in:
parent
28bd5e1b30
commit
edd60cff5c
@ -76,7 +76,7 @@ export function Console(props: IProps): React.ReactElement {
|
||||
}, []);
|
||||
|
||||
function handleKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
if (event.keyCode === 13) {
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
if (command.length > 0) {
|
||||
props.bladeburner.postToConsole("> " + command);
|
||||
@ -88,7 +88,7 @@ export function Console(props: IProps): React.ReactElement {
|
||||
|
||||
const consoleHistory = props.bladeburner.consoleHistory;
|
||||
|
||||
if (event.keyCode === 38) {
|
||||
if (event.key === "s") {
|
||||
// up
|
||||
let i = consoleHistoryIndex;
|
||||
const len = consoleHistory.length;
|
||||
@ -108,7 +108,7 @@ export function Console(props: IProps): React.ReactElement {
|
||||
setCommand(prevCommand);
|
||||
}
|
||||
|
||||
if (event.keyCode === 40) {
|
||||
if (event.key === "ArrowDown") {
|
||||
const i = consoleHistoryIndex;
|
||||
const len = consoleHistory.length;
|
||||
|
||||
|
@ -69,7 +69,7 @@ export function BuybackSharesModal(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
if (event.keyCode === 13) buy();
|
||||
if (event.key === "Enter") buy();
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -53,7 +53,7 @@ export function ExpandIndustryTab(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
if (event.keyCode === 13) newIndustry();
|
||||
if (event.key === "Enter") newIndustry();
|
||||
}
|
||||
|
||||
function onIndustryChange(event: SelectChangeEvent<string>): void {
|
||||
|
@ -45,7 +45,7 @@ export function GoPublicModal(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
if (event.keyCode === 13) goPublic();
|
||||
if (event.key === "Enter") goPublic();
|
||||
}
|
||||
|
||||
function onChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
||||
|
@ -32,7 +32,7 @@ export function IssueDividendsModal(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
if (event.keyCode === 13) issueDividends();
|
||||
if (event.key === "Enter") issueDividends();
|
||||
}
|
||||
|
||||
function onChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
||||
|
@ -93,7 +93,7 @@ export function IssueNewSharesModal(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
if (event.keyCode === 13) issueNewShares();
|
||||
if (event.key === "Enter") issueNewShares();
|
||||
}
|
||||
|
||||
function onChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
||||
|
@ -25,7 +25,7 @@ export function LimitProductProductionModal(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
if (event.keyCode === 13) limitProductProduction();
|
||||
if (event.key === "Enter") limitProductProduction();
|
||||
}
|
||||
|
||||
function onChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
||||
|
@ -165,7 +165,7 @@ export function MakeProductModal(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
if (event.keyCode === 13) makeProduct();
|
||||
if (event.key === "Enter") makeProduct();
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -68,7 +68,7 @@ function BulkPurchaseSection(props: IBPProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
if (event.keyCode === 13) bulkPurchase();
|
||||
if (event.key === "Enter") bulkPurchase();
|
||||
}
|
||||
|
||||
function onChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
||||
@ -123,7 +123,7 @@ export function PurchaseMaterialModal(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
if (event.keyCode === 13) purchaseMaterial();
|
||||
if (event.key === "Enter") purchaseMaterial();
|
||||
}
|
||||
|
||||
function onChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
||||
|
@ -46,7 +46,7 @@ export function SellMaterialModal(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
if (event.keyCode === 13) sellMaterial();
|
||||
if (event.key === "Enter") sellMaterial();
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -58,7 +58,7 @@ export function SellProductModal(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
if (event.keyCode === 13) sellProduct();
|
||||
if (event.key === "Enter") sellProduct();
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -68,7 +68,7 @@ export function SellSharesModal(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
if (event.keyCode === 13) sell();
|
||||
if (event.key === "Enter") sell();
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -57,7 +57,7 @@ export function ThrowPartyModal(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
if (event.keyCode === 13) throwParty();
|
||||
if (event.key === "Enter") throwParty();
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -37,7 +37,7 @@ export function CreateGangModal(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onKeyUp(event: React.KeyboardEvent): void {
|
||||
if (event.keyCode === 13) createGang();
|
||||
if (event.key === "Enter") createGang();
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -34,7 +34,7 @@ export function RecruitModal(props: IRecruitPopupProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onKeyUp(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
if (event.keyCode === 13) recruit();
|
||||
if (event.key === "Enter") recruit();
|
||||
}
|
||||
|
||||
function onChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
||||
|
@ -29,7 +29,7 @@ export function PurchaseServerModal(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function onKeyUp(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
if (event.keyCode === 13) tryToPurchaseServer();
|
||||
if (event.key === "Enter") tryToPurchaseServer();
|
||||
}
|
||||
|
||||
function onChange(event: React.ChangeEvent<HTMLInputElement>): void {
|
||||
|
@ -53,7 +53,6 @@ import { Settings } from "../../Settings/Settings";
|
||||
import { redPillFlag } from "../../RedPill";
|
||||
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
|
||||
|
||||
import { KEY } from "../../utils/helpers/keyCodes";
|
||||
import { ProgramsSeen } from "../../Programs/ui/ProgramsRoot";
|
||||
import { InvitationsSeen } from "../../Faction/ui/FactionsRoot";
|
||||
import { hash } from "../../hash/hash";
|
||||
@ -276,54 +275,54 @@ export function SidebarRoot(props: IProps): React.ReactElement {
|
||||
function handleShortcuts(this: Document, event: KeyboardEvent): any {
|
||||
if (Settings.DisableHotkeys) return;
|
||||
if ((props.player.isWorking && props.player.focus) || redPillFlag) return;
|
||||
if (event.keyCode == KEY.T && event.altKey) {
|
||||
if (event.key === "t" && event.altKey) {
|
||||
event.preventDefault();
|
||||
clickTerminal();
|
||||
} else if (event.keyCode === KEY.C && event.altKey) {
|
||||
} else if (event.key === "c" && event.altKey) {
|
||||
event.preventDefault();
|
||||
clickStats();
|
||||
} else if (event.keyCode === KEY.E && event.altKey) {
|
||||
} else if (event.key === "e" && event.altKey) {
|
||||
event.preventDefault();
|
||||
clickScriptEditor();
|
||||
} else if (event.keyCode === KEY.S && event.altKey) {
|
||||
} else if (event.key === "s" && event.altKey) {
|
||||
event.preventDefault();
|
||||
clickActiveScripts();
|
||||
} else if (event.keyCode === KEY.H && event.altKey) {
|
||||
} else if (event.key === "h" && event.altKey) {
|
||||
event.preventDefault();
|
||||
clickHacknet();
|
||||
} else if (event.keyCode === KEY.W && event.altKey) {
|
||||
} else if (event.key === "w" && event.altKey) {
|
||||
event.preventDefault();
|
||||
clickCity();
|
||||
} else if (event.keyCode === KEY.J && event.altKey && !event.ctrlKey && !event.metaKey && canJob) {
|
||||
} else if (event.key === "j" && event.altKey && !event.ctrlKey && !event.metaKey && canJob) {
|
||||
// ctrl/cmd + alt + j is shortcut to open Chrome dev tools
|
||||
event.preventDefault();
|
||||
clickJob();
|
||||
} else if (event.keyCode === KEY.R && event.altKey) {
|
||||
} else if (event.key === "r" && event.altKey) {
|
||||
event.preventDefault();
|
||||
clickTravel();
|
||||
} else if (event.keyCode === KEY.P && event.altKey) {
|
||||
} else if (event.key === "p" && event.altKey) {
|
||||
event.preventDefault();
|
||||
clickCreateProgram();
|
||||
} else if (event.keyCode === KEY.F && event.altKey) {
|
||||
} else if (event.key === "f" && event.altKey) {
|
||||
if (props.page == Page.Terminal && Settings.EnableBashHotkeys) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
clickFactions();
|
||||
} else if (event.keyCode === KEY.A && event.altKey) {
|
||||
} else if (event.key === "a" && event.altKey) {
|
||||
event.preventDefault();
|
||||
clickAugmentations();
|
||||
} else if (event.keyCode === KEY.U && event.altKey) {
|
||||
} else if (event.key === "u" && event.altKey) {
|
||||
event.preventDefault();
|
||||
clickTutorial();
|
||||
} else if (event.keyCode === KEY.B && event.altKey && props.player.bladeburner) {
|
||||
} else if (event.key === "b" && event.altKey && props.player.bladeburner) {
|
||||
event.preventDefault();
|
||||
clickBladeburner();
|
||||
} else if (event.keyCode === KEY.G && event.altKey && props.player.gang) {
|
||||
} else if (event.key === "g" && event.altKey && props.player.gang) {
|
||||
event.preventDefault();
|
||||
clickGang();
|
||||
}
|
||||
// if (event.keyCode === KEY.O && event.altKey) {
|
||||
// if (event.key === "o" && event.altKey) {
|
||||
// event.preventDefault();
|
||||
// gameOptionsBoxOpen();
|
||||
// }
|
||||
|
@ -6,7 +6,6 @@ import createStyles from "@mui/styles/createStyles";
|
||||
import TextField from "@mui/material/TextField";
|
||||
import Tooltip from "@mui/material/Tooltip";
|
||||
|
||||
import { KEY } from "../../utils/helpers/keyCodes";
|
||||
import { ITerminal } from "../ITerminal";
|
||||
import { IRouter } from "../../ui/Router";
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
@ -180,13 +179,13 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
||||
useEffect(() => {
|
||||
function keyDown(this: Document, event: KeyboardEvent): void {
|
||||
if (terminal.contractOpen) return;
|
||||
if (terminal.action !== null && event.keyCode === KEY.C && event.ctrlKey) {
|
||||
if (terminal.action !== null && event.key === "c" && event.ctrlKey) {
|
||||
terminal.finishAction(router, player, true);
|
||||
return;
|
||||
}
|
||||
const ref = terminalInput.current;
|
||||
if (event.ctrlKey || event.metaKey) return;
|
||||
if (event.keyCode === KEY.C && (event.ctrlKey || event.metaKey)) return; // trying to copy
|
||||
if (event.key === "c" && (event.ctrlKey || event.metaKey)) return; // trying to copy
|
||||
|
||||
if (ref) ref.focus();
|
||||
}
|
||||
@ -196,7 +195,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
||||
|
||||
async function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): Promise<void> {
|
||||
// Run command.
|
||||
if (event.keyCode === KEY.ENTER && value !== "") {
|
||||
if (event.key === "Enter" && value !== "") {
|
||||
event.preventDefault();
|
||||
terminal.print(`[${player.getCurrentServer().hostname} ~${terminal.cwd()}]> ${value}`);
|
||||
terminal.executeCommands(router, player, value);
|
||||
@ -205,7 +204,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
||||
}
|
||||
|
||||
// Autocomplete
|
||||
if (event.keyCode === KEY.TAB && value !== "") {
|
||||
if (event.key === "Tab" && value !== "") {
|
||||
event.preventDefault();
|
||||
|
||||
let copy = value;
|
||||
@ -256,13 +255,13 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
||||
}
|
||||
|
||||
// Clear screen.
|
||||
if (event.keyCode === KEY.L && event.ctrlKey) {
|
||||
if (event.key === "l" && event.ctrlKey) {
|
||||
event.preventDefault();
|
||||
terminal.clear();
|
||||
}
|
||||
|
||||
// Select previous command.
|
||||
if (event.keyCode === KEY.UPARROW || (Settings.EnableBashHotkeys && event.keyCode === KEY.P && event.ctrlKey)) {
|
||||
if (event.key === "ArrowUp" || (Settings.EnableBashHotkeys && event.key === "p" && event.ctrlKey)) {
|
||||
if (Settings.EnableBashHotkeys) {
|
||||
event.preventDefault();
|
||||
}
|
||||
@ -290,7 +289,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
||||
}
|
||||
|
||||
// Select next command
|
||||
if (event.keyCode === KEY.DOWNARROW || (Settings.EnableBashHotkeys && event.keyCode === KEY.M && event.ctrlKey)) {
|
||||
if (event.key === "ArrowDown" || (Settings.EnableBashHotkeys && event.key === "m" && event.ctrlKey)) {
|
||||
if (Settings.EnableBashHotkeys) {
|
||||
event.preventDefault();
|
||||
}
|
||||
@ -317,57 +316,57 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React
|
||||
|
||||
// Extra Bash Emulation Hotkeys, must be enabled through options
|
||||
if (Settings.EnableBashHotkeys) {
|
||||
if (event.keyCode === KEY.A && event.ctrlKey) {
|
||||
if (event.key === "a" && event.ctrlKey) {
|
||||
event.preventDefault();
|
||||
moveTextCursor("home");
|
||||
}
|
||||
|
||||
if (event.keyCode === KEY.E && event.ctrlKey) {
|
||||
if (event.key === "e" && event.ctrlKey) {
|
||||
event.preventDefault();
|
||||
moveTextCursor("end");
|
||||
}
|
||||
|
||||
if (event.keyCode === KEY.B && event.ctrlKey) {
|
||||
if (event.key === "b" && event.ctrlKey) {
|
||||
event.preventDefault();
|
||||
moveTextCursor("prevchar");
|
||||
}
|
||||
|
||||
if (event.keyCode === KEY.B && event.altKey) {
|
||||
if (event.key === "b" && event.altKey) {
|
||||
event.preventDefault();
|
||||
moveTextCursor("prevword");
|
||||
}
|
||||
|
||||
if (event.keyCode === KEY.F && event.ctrlKey) {
|
||||
if (event.key === "f" && event.ctrlKey) {
|
||||
event.preventDefault();
|
||||
moveTextCursor("nextchar");
|
||||
}
|
||||
|
||||
if (event.keyCode === KEY.F && event.altKey) {
|
||||
if (event.key === "f" && event.altKey) {
|
||||
event.preventDefault();
|
||||
moveTextCursor("nextword");
|
||||
}
|
||||
|
||||
if ((event.keyCode === KEY.H || event.keyCode === KEY.D) && event.ctrlKey) {
|
||||
if ((event.key === "h" || event.key === "d") && event.ctrlKey) {
|
||||
modifyInput("backspace");
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
if (event.keyCode === KEY.W && event.ctrlKey) {
|
||||
if (event.key === "w" && event.ctrlKey) {
|
||||
event.preventDefault();
|
||||
modifyInput("deletewordbefore");
|
||||
}
|
||||
|
||||
if (event.keyCode === KEY.D && event.altKey) {
|
||||
if (event.key === "d" && event.altKey) {
|
||||
event.preventDefault();
|
||||
modifyInput("deletewordafter");
|
||||
}
|
||||
|
||||
if (event.keyCode === KEY.U && event.ctrlKey) {
|
||||
if (event.key === "u" && event.ctrlKey) {
|
||||
event.preventDefault();
|
||||
modifyInput("clearbefore");
|
||||
}
|
||||
|
||||
if (event.keyCode === KEY.K && event.ctrlKey) {
|
||||
if (event.key === "k" && event.ctrlKey) {
|
||||
event.preventDefault();
|
||||
modifyInput("clearafter");
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { KEY } from "../../utils/helpers/keyCodes";
|
||||
|
||||
import { CodingContract, CodingContractTypes } from "../../CodingContracts";
|
||||
import { CopyableText } from "./CopyableText";
|
||||
@ -37,7 +36,7 @@ export function CodingContractModal(): React.ReactElement {
|
||||
// whatever ...
|
||||
const value = (event.target as any).value;
|
||||
|
||||
if (event.keyCode === KEY.ENTER && value !== "") {
|
||||
if (event.key === "Enter" && value !== "") {
|
||||
event.preventDefault();
|
||||
props.onAttempt(answer);
|
||||
setAnswer("");
|
||||
|
Loading…
Reference in New Issue
Block a user