42 lines
1.8 KiB
Plaintext
42 lines
1.8 KiB
Plaintext
|
|
-- File: keyboard._hs
|
||
|
|
-- Purpose: Keyboard shortcut handlers for CV application
|
||
|
|
-- Last Updated: 2025-11-20
|
||
|
|
|
||
|
|
-- Main keyboard event dispatcher
|
||
|
|
-- Handles all keyboard shortcuts: '?', 'L', 'I', 'V'
|
||
|
|
-- NOTE: This file is kept as reference/documentation only.
|
||
|
|
-- The actual keyboard handler is implemented inline in templates/index.html (body tag)
|
||
|
|
-- because hyperscript event handlers need direct access to the event context.
|
||
|
|
def handleGlobalKeydown(event)
|
||
|
|
set tagName to event.target.tagName
|
||
|
|
set isInputField to (tagName is 'INPUT' or tagName is 'TEXTAREA')
|
||
|
|
|
||
|
|
-- Show shortcuts modal with '?'
|
||
|
|
if event.key is '?' and not event.ctrlKey and not event.metaKey and not event.altKey and not isInputField
|
||
|
|
halt the event
|
||
|
|
set modal to #shortcuts-modal
|
||
|
|
if modal then call modal.showModal() end
|
||
|
|
end
|
||
|
|
|
||
|
|
-- Toggle CV length with 'L'
|
||
|
|
if (event.key is 'l' or event.key is 'L') and not event.ctrlKey and not event.metaKey and not event.altKey and not isInputField
|
||
|
|
halt the event
|
||
|
|
set lengthToggle to (#lengthToggle or #lengthToggleMenu)
|
||
|
|
if lengthToggle then set lengthToggle's checked to (not lengthToggle's checked) then send change to lengthToggle end
|
||
|
|
end
|
||
|
|
|
||
|
|
-- Toggle icons with 'I'
|
||
|
|
if (event.key is 'i' or event.key is 'I') and not event.ctrlKey and not event.metaKey and not event.altKey and not isInputField
|
||
|
|
halt the event
|
||
|
|
set iconToggle to (#iconToggle or #iconToggleMenu)
|
||
|
|
if iconToggle then set iconToggle's checked to (not iconToggle's checked) then send change to iconToggle end
|
||
|
|
end
|
||
|
|
|
||
|
|
-- Toggle theme with 'V'
|
||
|
|
if (event.key is 'v' or event.key is 'V') and not event.ctrlKey and not event.metaKey and not event.altKey and not isInputField
|
||
|
|
halt the event
|
||
|
|
set themeToggle to (#themeToggle or #themeToggleMenu)
|
||
|
|
if themeToggle then set themeToggle's checked to (not themeToggle's checked) then send change to themeToggle end
|
||
|
|
end
|
||
|
|
end
|