chess.com, wasd controls

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

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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.2
// @author       Tobias L
// @include      *.chess.com/*
// @license      GPL-3.0-only
// @namespace    https://github.com/WhiteG00se/User-Scripts
// ==/UserScript==

function simulateKeyPress(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('ArrowUp')
		// 	break
		case 'a':
			simulateKeyPress('ArrowLeft')
			break
		// case 's':
		// 	simulateKeyPress('ArrowDown')
		// 	break
		case 'd':
			simulateKeyPress('ArrowRight')
			break
	}
})