From 41b55de9646b995710b3c13f400ce60898a30b4e Mon Sep 17 00:00:00 2001 From: MinusGix Date: Wed, 10 Apr 2019 17:30:32 -0500 Subject: Pressing Tab inserts a Tab Character This would make so when you press tab and it does not find any autocomplete it will insert a tab character. This is useful behavior for writing code quickly in chat. --- client/client.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'client') diff --git a/client/client.js b/client/client.js index 380318e..4f77450 100644 --- a/client/client.js +++ b/client/client.js @@ -401,6 +401,8 @@ $('#chatinput').onkeydown = function (e) { var pos = e.target.selectionStart || 0; var text = e.target.value; var index = text.lastIndexOf('@', pos); + + var autocompletedNick = false; if (index >= 0) { var stub = text.substring(index + 1, pos).toLowerCase(); @@ -411,8 +413,14 @@ $('#chatinput').onkeydown = function (e) { if (nicks.length == 1) { insertAtCursor(nicks[0].substr(stub.length) + " "); + autocompletedNick = true; } } + + // Since we did not insert a nick, we insert a tab character + if (!autocompletedNick) { + insertAtCursor('\t'); + } } } -- cgit v1.2.1