UNPKG

js-draw

Version:

Draw pictures using a pen, touchscreen, or mouse! JS-draw is a drawing library for JavaScript and TypeScript.

18 lines (17 loc) 554 B
import sendKeyPressRelease from './sendKeyPressRelease.mjs'; /** Sets the content of the given `input` or textarea to be `text`. */ const fillInput = (input, text, { clear = false } = {}) => { const dispatchUpdate = () => { input.dispatchEvent(new InputEvent('input')); }; if (clear) { input.value = ''; dispatchUpdate(); } for (const character of text.split('')) { input.value += character; sendKeyPressRelease(input, character); dispatchUpdate(); } }; export default fillInput;