Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong keycode for focusing the search (I can prepare a PR) #58

Open
mr-pascal opened this issue Apr 13, 2023 · 0 comments
Open

Wrong keycode for focusing the search (I can prepare a PR) #58

mr-pascal opened this issue Apr 13, 2023 · 0 comments

Comments

@mr-pascal
Copy link

In two places, there is a check if a certain keydown event was triggered by the 191 key code to e.g. focus on the input search bar. Even though I think this is wrong or at least might not work on every machine.

At least on my (Ubuntu) Machine, using Brave Browser typing / doesn't result in the key code 191 but in 55 which is the keyCode for 7.

So instead of checking for the keyCode in the two places mentioned further down, but also in the other places I would suggest to use the event.key property instead.
So I would replace e.keyCode === 191 with e.key === '/'.

I verified with the following snippet, that it works accordingly. Also you can see that I type in / but the keyCode 55 is printed to the console.
Also after changing this locally the focus on the search input worked again.

document.addEventListener('keydown', function(e){
    console.log(e.keyCode);
    console.log(e.key);
});

image

The two places:

if (e.keyCode === 191 ) {

if (e.keyCode === 191

I don't mind preparing a PR/fix for the 191 case, but can also do so for the other ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant