chess.com, wasd controls

allows user to go back and forth using the keys a and d, w and s are commented out

ของเมื่อวันที่ 08-10-2022 ดู เวอร์ชันล่าสุด

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         chess.com, wasd controls
// @description  allows user to go back and forth using the keys a and d, w and s are commented out
// @version      1.1
// @author       Tobias L
// @include      *.chess.com/*
// @license      GPL-3.0-only
// @namespace    https://github.com/WhiteG00se/User-Scripts
// ==/UserScript==

function simulateKeyPress(event, key) {
	let keyPress = new KeyboardEvent('keydown', {
		key: key,
		code: key,
		bubbles: true,
		cancelable: true,
		view: window,
	})
	document.dispatchEvent(keyPress)
}

document.body.addEventListener('keydown', function (event) {
	switch (event.key) {
		// case 'w':
		// 	simulateKeyPress(event, 'ArrowUp')
		// 	break
		case 'a':
			simulateKeyPress(event, 'ArrowLeft')
			break
		// case 's':
		// 	simulateKeyPress(event, 'ArrowDown')
		// 	break
		case 'd':
			simulateKeyPress(event, 'ArrowRight')
			break
	}
})