Typewriter
Built inTypewriter sounds as you type: a key click, a softer space bar, and a bell on Return.
What it can do
input.observeKnows when you type in a pane and what kind of key it was — a letter, Space, Return, Backspace — never which key.soundPlays the sounds that come inside the addon.
Settings
Shown under the addon in Settings › Labs once it’s on.
| Setting | Type | Default | Details |
|---|---|---|---|
Volumevolume |
Number | 60 |
From 0 to 100. |
Bell on Returnbell |
Switch | On |
Sounds
key-1key-2key-3spacebackspacereturn
Turn it on
- Turn on Feature Preview in Settings › Advanced, or add
feature-preview = trueto yourconfig.toml. - Open Settings › Labs and switch Addons on.
- Switch Typewriter on. Its settings show up right under it.
Source
The whole addon is this script and its addon.toml.
-- Typewriter: a sound for every key typed into a pane.
-- `key.typed` says only what kind of key it was, never which one.
local keys = { "key-1", "key-2", "key-3" }
local last = 0
otty.on("key.typed", function(e)
local volume = otty.setting("volume") / 100
if volume <= 0 then
return
end
if e.kind == "enter" then
otty.sound.play(if otty.setting("bell") then "return" else "space", { volume = volume })
elseif e.kind == "space" then
otty.sound.play("space", { volume = volume })
elseif e.kind == "backspace" then
otty.sound.play("backspace", { volume = volume })
else
-- Never the same click twice in a row, so a run of keys doesn't buzz.
local n = math.random(1, #keys - 1)
if n >= last then
n += 1
end
last = n
otty.sound.play(keys[n], { volume = volume * 0.85 })
end
end)