MCPcopy Create free account
hub / github.com/candybox2/candybox2.github.io / addHotkeys

Method addHotkeys

code/main/TheComputer.ts:42–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40
41 // Private methods
42 private addHotkeys(): void{
43 // Hotkeys are added now
44 this.hotkeysAdded = true;
45
46 // Add the enter hotkey
47 this.getGame().addHotkey(new Hotkey("enter", new CallbackCollection(this.pressedEnter.bind(this))));
48
49 // Add hotkeys for each letter from a to z
50 for(var i = 97; i <= 122; i++){
51 this.getGame().addHotkey(new Hotkey(String.fromCharCode(i), new CallbackCollection(this.pressedKey.bind(this, String.fromCharCode(i)))));
52 }
53
54 // Same thing for the numbers from 0 to 9
55 for(var i = 48; i <= 57; i++){
56 this.getGame().addHotkey(new Hotkey(String.fromCharCode(i), new CallbackCollection(this.pressedKey.bind(this, String.fromCharCode(i)))));
57 this.getGame().addHotkey(new Hotkey("numpad" + String.fromCharCode(i), new CallbackCollection(this.pressedKey.bind(this, String.fromCharCode(i)))));
58 }
59
60 // Add the hotkey for the space key
61 this.getGame().addHotkey(new Hotkey("space", new CallbackCollection(this.pressedKey.bind(this, " "))));
62
63 // Add the hotkey for the delete key
64 this.getGame().addHotkey(new Hotkey("delete", new CallbackCollection(this.pressedDelete.bind(this))));
65 }
66
67 private addLine(line: TheComputerLine): void{
68 this.lines.push(line);

Callers 1

switchOnOffMethod · 0.95

Calls 3

addHotkeyMethod · 0.80
bindMethod · 0.80
getGameMethod · 0.45

Tested by

no test coverage detected