From fe2e607baad4de925f70ff9c3a27661ef927afe6 Mon Sep 17 00:00:00 2001 From: rxi Date: Sun, 13 Apr 2014 12:19:04 +0100 Subject: [PATCH] Changed up/down keys on inputbox to always set cursor to end --- lovebird.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lovebird.lua b/lovebird.lua index aa6eac6..6e65866 100644 --- a/lovebird.lua +++ b/lovebird.lua @@ -160,8 +160,8 @@ end
+ onkeydown="return onInputKeyDown(event);" + onsubmit="onInputSubmit(); return false;">
@@ -223,17 +223,19 @@ end inputHistory.index = 0; var onInputKeyDown = function(e) { var key = e.which || e.keyCode; + if (key != 38 && key != 40) return true; var b = document.getElementById("inputbox"); if (key == 38 && inputHistory.index < inputHistory.length - 1) { /* Up key */ inputHistory.index++; - b.value = inputHistory[inputHistory.index]; } if (key == 40 && inputHistory.index >= 0) { /* Down key */ inputHistory.index--; - b.value = inputHistory[inputHistory.index] || ""; } + b.value = inputHistory[inputHistory.index] || ""; + b.selectionStart = b.value.length; + return false; } /* Output buffer and status */