MCPcopy Index your code
hub / github.com/EmulatorJS/EmulatorJS / keyChange

Method keyChange

data/src/emulator.js:3324–3349  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

3322 return -1;
3323 }
3324 keyChange(e) {
3325 if (e.repeat) return;
3326 if (!this.started) return;
3327 if (this.controlPopup.parentElement.parentElement.getAttribute("hidden") === null) {
3328 const num = this.controlPopup.getAttribute("button-num");
3329 const player = this.controlPopup.getAttribute("player-num");
3330 if (!this.controls[player][num]) {
3331 this.controls[player][num] = {};
3332 }
3333 this.controls[player][num].value = e.keyCode;
3334 this.controlPopup.parentElement.parentElement.setAttribute("hidden", "");
3335 this.checkGamepadInputs();
3336 this.saveSettings();
3337 return;
3338 }
3339 if (this.settingsMenu.style.display !== "none" || this.isPopupOpen() || this.getSettingValue("keyboardInput") === "enabled") return;
3340 e.preventDefault();
3341 const special = [16, 17, 18, 19, 20, 21, 22, 23];
3342 for (let i = 0; i < 4; i++) {
3343 for (let j = 0; j < 30; j++) {
3344 if (this.controls[i][j] && this.controls[i][j].value === e.keyCode) {
3345 this.gameManager.simulateInput(i, j, (e.type === "keyup" ? 0 : (special.includes(j) ? 0x7fff : 1)));
3346 }
3347 }
3348 }
3349 }
3350 gamepadEvent(e) {
3351 if (!this.started) return;
3352 const gamepadIndex = this.gamepadSelection.indexOf(this.gamepad.gamepads[e.gamepadIndex].id + "_" + this.gamepad.gamepads[e.gamepadIndex].index);

Callers

nothing calls this directly

Calls 4

saveSettingsMethod · 0.95
isPopupOpenMethod · 0.95
getSettingValueMethod · 0.95
simulateInputMethod · 0.80

Tested by

no test coverage detected