Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 47 additions & 16 deletions keybind-cheatsheet/panel.luau
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,47 @@ local function callback(prefix, fn)
end

local KEY_LABELS = {
XF86AudioRaiseVolume = "Vol Up",
XF86AudioLowerVolume = "Vol Down",
XF86AudioMute = "Mute",
XF86AudioMicMute = "Mic Mute",
XF86MonBrightnessUp = "Bright Up",
XF86MonBrightnessDown = "Bright Down",
XF86AudioPlay = "Play/Pause",
XF86AudioPause = "Pause",
XF86AudioNext = "Next",
XF86AudioPrev = "Previous",
Print = "PrtSc",
Prior = "PgUp",
Next = "PgDn",
Return = "Enter",
Escape = "Esc",
xf86audioraisevolume = "Vol Up",
xf86audiolowervolume = "Vol Down",
xf86audiomute = "Mute",
xf86audiomicmute = "Mic Mute",
xf86monbrightnessup = "Bright Up",
xf86monbrightnessdown = "Bright Down",
xf86audioplay = "Play/Pause",
xf86audiopause = "Pause",
xf86audionext = "Next",
xf86audioprev = "Previous",
print = "PrtSc",
prtsc = "PrtSc",
prior = "PgUp",
page_up = "PgUp",
pageup = "PgUp",
next = "PgDn",
page_down = "PgDn",
pagedown = "PgDn",
["return"] = "Enter",
enter = "Enter",
escape = "Esc",
esc = "Esc",
space = "Space",
backspace = "Backspace",
delete = "Del",
del = "Del",
insert = "Ins",
ins = "Ins",
tab = "Tab",
home = "Home",
["end"] = "End",
caps_lock = "CapsLock",
capslock = "CapsLock",
num_lock = "NumLock",
numlock = "NumLock",
scroll_lock = "ScrollLock",
scrolllock = "ScrollLock",
up = "↑",
down = "↓",
left = "←",
right = "→",
btn_left = "Mouse Left",
btn_right = "Mouse Right",
btn_middle = "Mouse Middle",
Expand All @@ -101,7 +126,12 @@ local KEY_LABELS = {
}

local function formatKey(key)
return KEY_LABELS[key] or key:gsub("^mouse:", "Mouse ")
if key == nil or key == "" then return "" end
local exact = KEY_LABELS[key]
if exact ~= nil then return exact end
local lowered = KEY_LABELS[lower(key)]
if lowered ~= nil then return lowered end
return key:gsub("^mouse:", "Mouse ")
end

local function niriCategoryFor(action)
Expand Down Expand Up @@ -878,6 +908,7 @@ local function lifecycleState()
end

return {
formatKey = formatKey,
bindingAvailableInView = bindingAvailableInView,
bindingContentOpacity = bindingContentOpacity,
hiddenBindingCount = hiddenBindingCount,
Expand Down
2 changes: 1 addition & 1 deletion keybind-cheatsheet/plugin.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id = "kenn/keybind-cheatsheet"
name = "Keybind Cheatsheet"
version = "0.2.3"
version = "0.2.4"
plugin_api = 9
author = "kenn"
license = "MIT"
Expand Down
Loading