How do I detect if the '+' key is pressed (without the shift)

twitter logo ・1 min read

I want to trigger the KeyboardEvent for the '+' key even if the '=' key is pressed

'shift+=' is '+' on English keyboards, but on other keyboards, the key for which 'shift+key' is '+' might be different. How do I account for all such cases?

twitter logo DISCUSS (1)
markdown guide

when keydown and some other events, an event has key property that has name of your keyboard key button.

input.addEventListener('keydown', function(e) {
  if (e.key === '+') {
    // ... do your code
Classic DEV Post from Oct 22 '18

Who's looking for open source contributors? (October 22nd edition)

We're towards the end of #hacktoberfest! Find something to work on or promote ...

Arnav Bansal profile image
I slay dragonsβ€”or take them as pets.

Sore eyes? now has dark mode.

Go to the "misc" section of your settings and select night theme ❀️