From 6390750ae5c85d0e64ca26660aa08b7220f07c58 Mon Sep 17 00:00:00 2001 From: raven Date: Sun, 15 Jan 2023 22:03:13 -0500 Subject: [PATCH] moving events to where they make sense --- sshChat.js | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/sshChat.js b/sshChat.js index a008f32..6988f41 100644 --- a/sshChat.js +++ b/sshChat.js @@ -52,6 +52,27 @@ const screen = blessed.screen({ fastCSR: true }); +// Quit on Escape, q, or Control-C. +screen.key(['escape', 'q', 'C-c'], function (ch, key) { + console.log("Sending close message...") + for (let conn of conns) { + conn.write(`CLOSED: ${publicKey.toString('hex')}`) + } + (async () => { + + await sleep(2000) + process.exit() + + })(); + +}); + +let scrollCount = 0 + +// Return to chat +screen.key(['t', 'enter'], function (ch, key) { + stdinBox.focus(); +}); // Debug ONLY // screen.on('keypress', function(ch, key){ @@ -312,26 +333,4 @@ stdinBox.on('submit', (input) => { stdinBox.focus(); // Render the screen -screen.render() - -// Quit on Escape, q, or Control-C. -screen.key(['escape', 'q', 'C-c'], function (ch, key) { - console.log("Sending close message...") - for (let conn of conns) { - conn.write(`CLOSED: ${publicKey.toString('hex')}`) - } - (async () => { - - await sleep(2000) - process.exit() - - })(); - -}); - -let scrollCount = 0 - -// Return to chat -screen.key(['t', 'enter'], function (ch, key) { - stdinBox.focus(); -}); \ No newline at end of file +screen.render() \ No newline at end of file