ctrl+d/r event handler (resume)

This commit is contained in:
b1ek 2023-03-18 12:46:38 +10:00
parent cb064c8053
commit bf6fb94e7c
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 34 additions and 10 deletions

View File

@ -135,7 +135,7 @@ function backspace(isCtrl) {
} }
/** @param { KeyboardEvent } dom */ /** @param { KeyboardEvent } dom */
function control_char(id, dom) { async function control_char(id, dom) {
switch (id) { switch (id) {
@ -167,18 +167,42 @@ function control_char(id, dom) {
case 86: case 86:
if (dom.altKey) break; if (dom.altKey) break;
default: case 82:
if (dom.ctrlKey && (dom.key.length == 1)) { // Why it checks if letter is 'r':
terminal.write('^' + dom.key.toUpperCase()); // For some reason, ctrl+(v|r|d) executed this code.
// This is a simple fix
// (same works for any other code like this in this function)
if (dom.ctrlKey && dom.key.toLowerCase() == 'r') {
if (Math.random() < 0.1) terminal.write('uwu');
window.location.reload();
break;
}
case 68:
if (dom.ctrlKey && dom.key.toLowerCase() == 'd') {
terminal.writeln('');
pr_char = () => {};
exec_cmd = pr_char;
control_char = () => {};
break; break;
} }
terminal.write('<'); default:
if (dom.ctrlKey) terminal.write('C'); const wr = (t) => {
if (dom.altKey) terminal.write('A'); terminal.write(t);
if (dom.shiftKey) terminal.write('S'); cmd += t;
terminal.write(`${id}>`) }
if (dom.ctrlKey && (dom.key.length == 1)) {
wr('^' + dom.key.toUpperCase());
break;
}
wr('<');
if (dom.ctrlKey) wr('C');
if (dom.altKey) wr('A');
if (dom.shiftKey) wr('S');
wr(`${id}>`)
break; break;
} }
} }