Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue 3 Support #31

Open
fatalis opened this issue Aug 30, 2020 · 4 comments · May be fixed by #48
Open

Vue 3 Support #31

fatalis opened this issue Aug 30, 2020 · 4 comments · May be fixed by #48

Comments

@fatalis
Copy link

fatalis commented Aug 30, 2020

here's a way to use in Vue 3 in the mean time if anyone needs this:

app.directive('hotkey', {
  beforeMount: VueHotkey.directive.bind,
  updated: VueHotkey.directive.componentUpdated,
  unmounted: VueHotkey.directive.unbind,
});

@ayophanz
Copy link

ayophanz commented Mar 22, 2021

Still not working, see images
image
image
image

@Nihilop
Copy link

Nihilop commented May 3, 2021

work for me :

main.ts

 app.directive('hotkey', {
    beforeMount: VueHotkey.directive.bind,
    updated: VueHotkey.directive.componentUpdated,
    unmounted: VueHotkey.directive.unbind,
  }); 

file.vue

data() {
  return {
     searchPanel: false,
  }
},
methods: {
   showSearch() {
      console.log('opened')
      this.searchPanel = !this.searchPanel
    }
  },
  computed: {
    openSearch() {
      return {
        'ctrl+f: { 
          keyup: this.showSearch
        }
      }
    }
  }
<span v-show="searchPanel" v-hotkey.prevent='openSearch'>Blabla</span>

note : v-hotkey as attr and openSearch (computed)

@scott-fryxell
Copy link

I have this working in vue3, but my tests that use the directive fail.

[Vue warn]: Failed to resolve directive: hotkey
at
at

@semiaddict semiaddict linked a pull request Feb 27, 2022 that will close this issue
@wobsoriano
Copy link

wobsoriano commented Dec 13, 2022

Published a fork in the meantime https://github.com/wobsoriano/v-hotkey3

With added useHotkey composable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants