Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.child.keyEventInput.subscribe(e => {
console.log('keyboard event:' + e.domEvent.keyCode + ', ' + e.key);
const ev = e.domEvent;
const printable = !ev.altKey && !ev.ctrlKey && !ev.metaKey;
if (ev.keyCode === 13) {
this.child.write('\n' + FunctionsUsingCSI.cursorColumn(1) + '$ '); // \r\n
} else if (ev.keyCode === 8) {
// Do not delete the prompt
if (this.child.underlying.buffer.cursorX > 2) {
this.child.write('\b \b');
}
} else if (printable) {
this.child.write(e.key);
}
})
this.rowsControl.valueChanges.subscribe(() => { this.invalidate() });