hotkeys-js icon indicating copy to clipboard operation
hotkeys-js copied to clipboard

spaming ctrl with = or - triggers native browser zoom event

Open achenPDFTron opened this issue 5 years ago • 3 comments

Steps to reproduce:

  1. use hotkey manager to set up hot keys for "ctrl+=" and "ctrl+-"
  2. in the application, hold "ctrl" and rapidly alternate between "=" and "-"

Observe: the native browser zoom event is triggered

Somehow this issue can't be reproduced in the demo.

Workaround for now:

window.addEventListener('keydown', e => {
  if (e.ctrlKey) {
    if (e.which === 187 || e.which === 189) {
      e.preventDefault();
    }
  }
});

achenPDFTron avatar Jun 22 '20 18:06 achenPDFTron

@achenPDFTron thx! I research your solution.

jaywcjlove avatar Jun 23 '20 02:06 jaywcjlove

@jaywcjlove Thanks for taking the time to look into this problem.

achenPDFTron avatar Jun 23 '20 15:06 achenPDFTron

i just found the solution! you should write:

hotkeys('ctrl+=', kv => {
   kv.preventDefault()
   ....
})

hamidb80 avatar Feb 12 '21 16:02 hamidb80