N
Nuxt2mo ago
StefanH

defineShortcut(): meta key doesn't work on linux?

Hey I'm running an arch linux system with kde plasma and firefox. Shortcuts with meta_ don't work for me at all. Now I understand linux is always iffy but this does seem like a bug to me right now. Want to ask if others have the same issue on other distros before i open an issue my code:
onMounted(() => {
defineShortcuts({
meta_k: (e) => {
console.log("Shortcut pressed", e);
}
}
}
onMounted(() => {
defineShortcuts({
meta_k: (e) => {
console.log("Shortcut pressed", e);
}
}
}
any other letters don't work either. When i change it to ctrl it works
3 Replies
kapa.ai
kapa.ai2mo ago
Hi @StefanH. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the knowledge sources, I can offer some insights about the defineShortcuts functionality in Nuxt, but I don't have specific information about its behavior on Linux systems. However, I can provide some relevant information and suggestions. The defineShortcuts composable is part of the Nuxt UI library and is designed to handle keyboard shortcuts in Nuxt applications. According to the Shortcuts documentation, the meta key is supposed to act as the Command key on macOS and the Control key on other operating systems. Here's what we know: 1. The meta key should work as Control on non-macOS systems, including Linux. 2. The syntax you're using (meta_k) is correct according to the documentation. 3. The documentation doesn't mention any specific issues with Linux systems. Given that ctrl works for you but meta doesn't, there might be a few possibilities: 1. There could be an issue with how the meta key is interpreted on your specific Linux distribution or desktop environment. 2. There might be a bug in the Nuxt UI library's handling of the meta key on Linux systems. 3. Your system's keyboard layout or configuration might be affecting how the meta key is recognized. Before opening an issue, you could try the following: 1. Use the useShortcuts composable to check how the meta key is being interpreted:
const { metaSymbol } = useShortcuts()
console.log(metaSymbol) // This should log either "⌘" on macOS or "Ctrl" on other OS
const { metaSymbol } = useShortcuts()
console.log(metaSymbol) // This should log either "⌘" on macOS or "Ctrl" on other OS
2. Try using explicit ctrl instead of meta for Linux systems:
onMounted(() => {
defineShortcuts({
[`${process.client && navigator.platform.toLowerCase().includes('linux') ? 'ctrl' : 'meta'}_k`]: (e) => {
console.log("Shortcut pressed", e);
}
})
})
onMounted(() => {
defineShortcuts({
[`${process.client && navigator.platform.toLowerCase().includes('linux') ? 'ctrl' : 'meta'}_k`]: (e) => {
console.log("Shortcut pressed", e);
}
})
})
If these suggestions don't resolve the issue, and you confirm that other Linux users are experiencing the same problem, it would be appropriate to open an issue on the Nuxt UI GitHub repository. When reporting the bug, make sure to follow the guidelines outlined in the Reporting Bugs documentation, including creating a minimal reproduction of the issue. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@211558054947192834> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
StefanH
StefanHOP2mo ago
useShortcuts is ui2 i use ui3 Okay I found out what the problem is. meta maps to the "windows" key on linux. so i have to press windows+k. i see "meta" used to describe the "windows" key in linux spaces a lot so i was wondering why that word was used to mean control here

Did you find this page helpful?