Mostafa-Abbasi / KeyboardTester

A Tool that Tests Keyboard Functionality, Made with HTML/CSS/JS
https://mostafa-abbasi.github.io/KeyboardTester/
MIT License
10 stars 1 forks source link

The right `Alt` should be `Alt Gr` and should be an independent Key #4

Closed shoulders closed 1 week ago

shoulders commented 6 months ago

image

IMG20240407080629

Proposed solution

Mostafa-Abbasi commented 1 week ago

I'm thinking that I should keep the Alt (as right Alt) and not change its legend to Alt Gr, because that is not familiar to most users. but also check for Alt Gr code when it is pressed for the sake of completeness, unfortunately I couldn't find the code for Alt Gr key, if you know its exact code, I can implement this feature. Reference: https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_code_values

shoulders commented 1 week ago

Alt right is wrong because you don't call the left one alt left. Definitely use Alt Gr.

People might know the key as the alt right because it is an alt key on the right hand side.

The enter and return keys are different keys but normal people assume they are the same.

It is best to keep the property names as this is what leads to people using their simple names.

I will see if I can find the keycode for you

Thanks

shoulders commented 1 week ago

looks like there is no longer a specific code for AltGr so people emulate it

if (event.ctrlKey && event.altKey) {
    // Appears to be Alt Gr
}
Mostafa-Abbasi commented 1 week ago

Alright, I added the code to detect the AltGr key press, now if you press it, Right Alt should be highlighted. (which is in the same physical location). Test it and tell me if it is working as expected.

shoulders commented 1 week ago

2 things

Mostafa-Abbasi commented 1 week ago

Alright! I think I finally fixed it! It should now correctly detect the AltGr with the help of e.key. Test and see how it goes! 😄 Thanks for the feedbacks btw.

shoulders commented 1 week ago

Your welcome, thanks for the keyboard tester.

Mostafa-Abbasi commented 1 week ago

Glad to hear that it works. That flickering issue must be the delay of the browser to execute this part of the code:

document.querySelector('.' + 'controlleft').classList.remove('key-pressing-simulation');
document.querySelector('.' + 'controlleft').classList.remove('key--pressed');

I think the current implementation is good enough, if I figured out a better solution, I will replace it.