interface TtydTerminal extends Terminal { fit(): void; } declare global { interface Window { term: TtydTerminal; } }
ttyd exposes the xterm.js Terminal instance via window.term, and a fit() function on it (see fit addon).
window.term
fit()
var script = document.createElement('script'); script.src = 'https://unpkg.com/keysim@latest/dist/keysim.js'; script.onload = function() { var input = document.querySelector('textarea'); var keyboard = Keysim.Keyboard.US_ENGLISH; keyboard.dispatchEventsForInput("ls", input); keyboard.dispatchEventsForAction("enter", input); }; document.body.appendChild(script);
term.paste("whoami"); document.querySelector("textarea.xterm-helper-textarea").dispatchEvent(new KeyboardEvent('keypress', {charCode: 13}))
document.getElementById('youriframeid').contentWindow.term.paste("whoami"); document.getElementById('youriframeid').contentDocument.querySelector("textarea.xterm-helper-textarea").dispatchEvent(new KeyboardEvent('keypress', {charCode: 13}))
There was an error while loading. Please reload this page.