Merge pull request #13 from Ghetreek/patch-1

Fix isCtrlEnter switch
This commit is contained in:
Özenç Bilgili 2021-08-06 23:10:39 +03:00 committed by GitHub
commit 23ab5223d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,7 @@ class Form {
this._categoryLaunch = options.categoryLaunch;
this._clearPreview = this._clearPreview.bind(this);
this._handleInput = this._handleInput.bind(this);
this._handleKeyup = this._handleKeyup.bind(this);
this._handleKeydown = this._handleKeydown.bind(this);
this._previewValue = this._previewValue.bind(this);
this._submitForm = this._submitForm.bind(this);
@ -94,8 +95,11 @@ class Form {
if (isCategoryLaunch) this._categoryLaunch();
if (this._instantRedirect && isKey) this._submitWithValue(newQuery);
}
_handleKeyup(e) {
if ($.key(e) == 'ctrl') this.isCtrlEnter = false;
}
_handleKeydown(e) {
if ($.isUp(e) || $.isDown(e) || $.isRemove(e)) return;
@ -132,6 +136,7 @@ class Form {
}
_registerEvents() {
document.addEventListener('keyup', this._handleKeyup);
document.addEventListener('keydown', this._handleKeydown);
this._inputEl.addEventListener('input', this._handleInput);
this._formEl.addEventListener('submit', this._submitForm, false);
@ -161,4 +166,4 @@ class Form {
this._inputEl.value = value;
this._submitForm();
}
}
}