Dafrok/v-hotkey

how can i disable ctrl+r for web Browser

yyman001 opened this issue · 4 comments

Hi,
how can i disable ctrl+r for web Browser,when i must use ctrl + r to show rulers, but it will refresh browser...
i try it no work

  event.stopPropagation()
  event.preventDefault()
  event.keyCode = false
  event.returnValue = false
  window.event.keyCode = false

do you know how to disable ? thanks~

I tried and found that preventDefault has just worked. I mean there might be other problems with your code, how about show that to me?

@Dafrok about my code

<span v-hotkey="keymap" class="hotkey"></span>
      computed: {
        keymap () {
          return {
            'ctrl+esc': this.toggle,
            'ctrl+z': this.ctrlZ,
            'ctrl+shift+z': this.ctrlShift,
            'ctrl+r':this.rulers,
            'enter': {
              keydown: this.enterDown,
              keyup: this.enterUp
            }
          }
        }
      },
      methods: {
        toggle () {

        },
        ctrlZ (event) {
          console.log('event:', event)
          if (!this.ctrlZDisable) {
            console.log('撤销');
            this.preStep()
          }
        },
        ctrlShift (event) {
          if (!this.ctrlShiftDisable) {
            console.log('恢复');
            this.nextStep()
          }
        },
        rulers (event) {
          event.stopPropagation()
          event.preventDefault()
          event.keyCode = 0
          event.returnValue = false
          window.event.keyCode = false
          window.event.returnValue= false
          console.log('标尺',event)
        },
        enterDown () {
          console.log('enterDown')
        },
        enterUp () {
          console.log('enterUp')
        }
}

is preventDefault breaks in every browsers?

in electron,fuck the electron.in the browsers is work.