From 98f54d5832385e8b9e373eb946e6b184e84b6a1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zen=C3=A7=20Bilgili?= Date: Tue, 19 May 2020 00:27:03 +0300 Subject: [PATCH] Add Ctrl + Enter support --- js/script.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/js/script.js b/js/script.js index 4a6110e..21b244d 100644 --- a/js/script.js +++ b/js/script.js @@ -250,7 +250,7 @@ const $ = { case 9: return shift ? 's-tab' : 'tab'; case 13: - return 'enter'; + return ctrl ? 'c-enter' : 'enter'; case 16: return 'shift'; case 17: @@ -839,6 +839,7 @@ class Form { this._registerEvents(); this._loadQueryParam(); this.invert(); + this.isCtrlEnter = false; } hide() { @@ -902,17 +903,19 @@ class Form { _handleKeydown(e) { if ($.isUp(e) || $.isDown(e) || $.isRemove(e)) return; - + switch ($.key(e)) { case 'alt': case 'ctrl': - case 'enter': + case 'enter': case 'shift': case 'super': return; case 'escape': this.hide(); return; + case 'c-enter': + this.isCtrlEnter = true; } this.show(); @@ -952,9 +955,10 @@ class Form { _submitForm(e) { if (e) e.preventDefault(); - const query = this._inputEl.value; + let query = this._inputEl.value; if (this._suggester) this._suggester.success(query); this.hide(); + if (this.isCtrlEnter) query += '.com'; this._redirect(this._parseQuery(query).redirect); }