Sha256: 47fb8d356891355f1c4627a7c3c45aa6b985c5c9ffbb2553545000ca1b2a002b
Contents?: true
Size: 1.48 KB
Versions: 26
Compression:
Stored size: 1.48 KB
Contents
import '../utils/click/isClickableInput.js'; import '../utils/dataTransfer/Clipboard.js'; import '../utils/edit/isEditable.js'; import '../utils/edit/maxLength.js'; import '../utils/keyDef/readNextDescriptor.js'; import '../utils/misc/level.js'; import { wait } from '../utils/misc/wait.js'; import '../options.js'; import { parseKeyDef } from './parseKeyDef.js'; async function keyboard(text) { const actions = parseKeyDef(this.config.keyboardMap, text); for(let i = 0; i < actions.length; i++){ await wait(this.config); await keyboardAction(this, actions[i]); } } async function keyboardAction(instance, { keyDef, releasePrevious, releaseSelf, repeat }) { const { system } = instance; // Release the key automatically if it was pressed before. if (system.keyboard.isKeyPressed(keyDef)) { await system.keyboard.keyup(instance, keyDef); } if (!releasePrevious) { for(let i = 1; i <= repeat; i++){ await system.keyboard.keydown(instance, keyDef); if (i < repeat) { await wait(instance.config); } } // Release the key only on the last iteration on `state.repeatKey`. if (releaseSelf) { await system.keyboard.keyup(instance, keyDef); } } } async function releaseAllKeys(instance) { for (const k of instance.system.keyboard.getPressedKeys()){ await instance.system.keyboard.keyup(instance, k); } } export { keyboard, releaseAllKeys };
Version data entries
26 entries across 26 versions & 1 rubygems