Implement keyboard typing sound feedback and refactor login sound handling

- Added a keyboard typing sound effect that plays on character input in App.vue for enhanced user interaction.
- Refactored the playSciFiTypingTick function in useLoginSounds.ts, replacing it with playKeyboardTypingSound for a more cohesive audio experience.
- Removed unnecessary keydown event handlers from Login.vue to streamline the code and improve clarity.
- Updated CLI store to play navigation sounds when toggling the CLI visibility.
This commit is contained in:
Dorian
2026-02-18 10:37:26 +00:00
parent c9f6e6b8ae
commit 578551f617
4 changed files with 27 additions and 47 deletions
+18 -36
View File
@@ -172,45 +172,27 @@ export function playTypingTick() {
a.play().catch(() => {})
}
/** Sci-fi typing sound - short synth blip + click per key, for login/password fields */
export function playSciFiTypingTick() {
const ctx = getContext()
if (!ctx) return
/** Keyboard input sound - plays on any character typed in inputs. Separate from typing tick/intro typing. */
let keyboardInputPool: HTMLAudioElement[] = []
const KEYBOARD_INPUT_POOL_SIZE = 5
try {
if (ctx.state === 'suspended') ctx.resume()
} catch {
return
function getKeyboardInputSound(): HTMLAudioElement {
if (keyboardInputPool.length === 0) {
for (let i = 0; i < KEYBOARD_INPUT_POOL_SIZE; i++) {
const a = new Audio('/assets/audio/typing.mp3')
a.volume = 0.5
keyboardInputPool.push(a)
}
}
const a = keyboardInputPool.shift()!
keyboardInputPool.push(a)
return a
}
const t = ctx.currentTime
// Main tone
const osc = ctx.createOscillator()
const gain = ctx.createGain()
osc.type = 'sine'
osc.frequency.setValueAtTime(880, t)
osc.frequency.exponentialRampToValueAtTime(660, t + 0.03)
gain.gain.setValueAtTime(0, t)
gain.gain.linearRampToValueAtTime(0.08, t + 0.005)
gain.gain.exponentialRampToValueAtTime(0.001, t + 0.06)
osc.connect(gain)
gain.connect(ctx.destination)
osc.start(t)
osc.stop(t + 0.06)
// Click - short transient at key press
const clickOsc = ctx.createOscillator()
const clickGain = ctx.createGain()
clickOsc.type = 'square'
clickOsc.frequency.setValueAtTime(1200, t)
clickGain.gain.setValueAtTime(0, t)
clickGain.gain.linearRampToValueAtTime(0.04, t + 0.001)
clickGain.gain.exponentialRampToValueAtTime(0.001, t + 0.012)
clickOsc.connect(clickGain)
clickGain.connect(ctx.destination)
clickOsc.start(t)
clickOsc.stop(t + 0.012)
export function playKeyboardTypingSound() {
const a = getKeyboardInputSound()
a.currentTime = 0
a.play().catch(() => {})
}
/** Gaming-style boot thud - soft impact when dashboard loads */