Skip to content

Commit

Permalink
fix keycode problem
Browse files Browse the repository at this point in the history
  • Loading branch information
m-primo committed Oct 17, 2021
1 parent ba57b38 commit 3644641
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ function getName(name, i = 0) {

function KeyCode(event) {
let code;
if(event.key !== undefined) {
code = event.key;
} else if(event.keyIdentifier !== undefined) {
if(event.keyIdentifier !== undefined) {
code = event.keyIdentifier;
} else if(event.keyCode !== undefined) {
code = event.keyCode;
Expand Down Expand Up @@ -218,8 +216,8 @@ getName('q', 0).focus();
getName('q', 0).addEventListener('keyup', function(e){
e.preventDefault();
const key_code = KeyCode(e);
if(key_code === 13) doSearch();
if(key_code === 27) clearSearch();
if(key_code == 13) doSearch();
if(key_code == 27) clearSearch();
});

getID('click-to-clear-search').onclick = function(){
Expand Down

0 comments on commit 3644641

Please sign in to comment.