Dafrok/v-hotkey

"NumPad +" won't assign

nzxt opened this issue · 15 comments

nzxt commented

Can't assign Numpad + as hotkey, but Numpad - works like a charm.

      keymap () {
        return {
          'numpad -': this.volumeDown,
          'numpad +': this.volumeUp
        }
      }

Where to dig in? Thanks!

i'm having a same issue

I doubt it's a problem caused by wrong key code.
Try putting the line below into your devtool, and then press the numpad +, tell me that key code in console.

document.addEventListener('keypress', e => console.log(e.keyCode))
nzxt commented

Yes, it says numpad+ has keycode '43', like generic '+'.
How to overide 'numpad+' keycode or use code numbers like '43 'instead of 'numpad +'?
And how to assign generic '+', like 'alt+ +' or not?

Just bind your handler handler to a generic + key should resolve your problem. That numpad + works when the numslock is off I guess.

nzxt commented

numslock does not affects. numpad - work well in any conditions.
Please, show on how to assign generic + with alt, for example

keymap () {
    return {
        'alt+ +': this.volumeUp
    }
}

or not? Or maybe add plus(=43) as keyword ('alt+plus': this.volumeUp)?

That's really a problem as I forgot the + is a key and it is also an operator. So I published a new version which modified the key map just now. Now you can use alt++ / alt + + / alt + add to resolve your problem.

nzxt commented

Great thanks! I'll try a bit later. Kewl module. I'm lovin' it!

nzxt commented

Won't work in v0.2.1 %(
In any variations alt++ / alt + + / alt + add console logs keycode 43, but assigned method doesn't envokes. Binding volumeUp to any other numpad's key - work great.

I have no keyboards with a numpad, so I can't catch the problem. But, I found there is something different betweenkeypress and keydown.

Try this code and tell me the result:

document.addEventListener('keydown', e => console.log(e.keyCode))

Try alt+numpad + in version 0.2.2, I took a few change

nzxt commented

Tried alt+numpad + / alt + numpad add / numpad + / numpad add but with no luck. Can't figure it out too..
keydown says keycode '+' = 43, keycode '-' = 45, all seems to be ok.
Thanks for your participation ;)

wft, it seems that I should buy a keyboard with numpad for testing

I have published version 0.2.3, I hope that is my last try for this

nzxt commented

Sorry, but no luck w/ this bug %)

Maybe resolved in #14