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

[Bug]: Ctrl is not working with useMagicKeys #429

Closed
jd-solanki opened this issue Apr 7, 2021 · 3 comments
Closed

[Bug]: Ctrl is not working with useMagicKeys #429

jd-solanki opened this issue Apr 7, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@jd-solanki
Copy link
Contributor

Your provided code snippet which includes Ctrl example also isn't working.

I even tried it in Vue 3 with a fresh installation.

Isn't working (From docs page)

<script setup>
import { watch }  from 'vue'
import { useMagicKeys } from '@vueuse/core'

const keys = useMagicKeys()
const shiftCtrlA = keys['Shift+Ctrl+A']

watch(shiftCtrlA, (v) => {
  if (v)
    console.log('Shift + Ctrl + A have been pressed')
})
</script>

Works (ctrl is removed)

<script setup>
import { watch }  from 'vue'
import { useMagicKeys } from '@vueuse/core'

const keys = useMagicKeys()
const shiftCtrlA = keys['Shift+A']

watch(shiftCtrlA, (v) => {
  if (v)
    console.log('Shift + Ctrl + A have been pressed')
})
</script>

Isn't working

<script setup>
import { watch }  from 'vue'
import { useMagicKeys } from '@vueuse/core'

const keys = useMagicKeys()
const shiftCtrlA = keys['Ctrl+A']

watch(shiftCtrlA, (v) => {
  if (v)
    console.log('Shift + Ctrl + A have been pressed')
})
</script>
@wheatjs wheatjs added the bug Something isn't working label Apr 7, 2021
@wheatjs
Copy link
Member

wheatjs commented Apr 7, 2021

Thanks for the report, can confirm it is not working. As a workaround until we get this fixed you can use control instead of ctrl. You can also use controlLeft and controlRight. We can see if @antfu wants to rename control to ctrl though since that seems like his original intention.

@antfu antfu closed this as completed in ed5d0cc Apr 8, 2021
@jd-solanki
Copy link
Contributor Author

Hi @antfu using

const { Ctrl_k } = useMagicKeys()

Opens browser search along with hotkey trigger. But if you check VueUse docs, triggering ctrl+k doesn't open browser search.

So do we have anything which doesn't open browser search or in general disable system/app hotkeys?

@antfu
Copy link
Member

antfu commented Apr 9, 2021

I would say it's better to avoid overriding system hotkeys. But if you want, you can do it by:
https://vueuse.org/core/useMagicKeys/#custom-event-handler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants