#global shortcut not registering

4 messages · Page 1 of 1 (latest)

astral vine
#

With this code:

<script lang="ts">
  import { register, unregisterAll } from '@tauri-apps/api/globalShortcut'
  async function test() {
    await unregisterAll();
    await register('CommandOrControl+Shift+C', () => {
      console.log('shortcut works')
    })
  }
  test()
</script>

<h1>hi</h1>

It gives this error in the console: Unable to register accelerator with `RegisterHotKey`
I am on windows 11. I have properly added the "globalShortcut" to the allowlist in tauri.conf.json

I believe it is probably a simple fix, but I am at the end of my wits nonetheless.

coral drum
#

Did you ever find a solution? I'm facing the exact same problem right now, but on Linux + Wayland. I even copied your code snippet and it gives me

[Error] Unhandled Promise Rejection: Unable to register global shortcut
    (anonymous function) (+page.svelte:511)
coral drum
#

Actually if these are proper global shortcuts that are expected to work even when the app is not focused, it makes sense why it wouldn't work for me since global shortcuts only recently got introduced into the Wayland protocol

kind dawn
#

Yep no global shortcuts on Wayland yet