Friday 16 November 2018

Detecting backspace in socket data (without key events; \b isn't working)

I'm writing a telnet server and I want to detect backspace without the client-user needing to configure their telnet app.The script handling keypresses and acting on data, receives the keypresses via net socket in realtime. So when the user makes a typo and then presses backspace, I'm trying this:else if (data.indexOf("\b") != -1 || data.indexOf("\u2408") != -1 || data.indexOf("\u0008") != -1) { // handle backspace console.log("Backspace detected"); this.currentInput = this.currentInput.substring(0, this.currentInput.length - 1); } There's gotta be a way to do this without access to key events, right?EDIT: updated source and added this note: the console.log("Backspace detected") never happens, but also the test data contains no garbage characters; just the typo plus the correction. E.g. if I type tesd(backspace)t into the terminal and hit enter, the server receives tesdt.EDIT: updated source again, still no luckEDIT: the data isn't being manipulated: this.socket.on('data', (data) => { this.onSocketData(data); });

Submitted November 16, 2018 at 11:46PM by poor-toy-soul-doll

No comments:

Post a Comment