From 609531434145850ac0a1f0827ed849a00c7f9d7a Mon Sep 17 00:00:00 2001 From: Dan Cojocaru Date: Wed, 13 Jul 2022 01:24:00 +0300 Subject: [PATCH] Go back only if focused input is empty --- back.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back.js b/back.js index 0c8361b..909bf61 100644 --- a/back.js +++ b/back.js @@ -1,6 +1,6 @@ window.addEventListener('load', function (e) { this.document.body.addEventListener('keydown', function (e) { - if (e.key == 'Backspace') { + if (e.key == 'Backspace' && (e.target.tagName.toUpperCase() !== 'INPUT' || e.target.value.length === 0)) { e.preventDefault() window.history.back() }