OttyAddons
All addons

Typewriter

Built in

Typewriter 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.

SettingTypeDefaultDetails
Volumevolume Number 60 From 0 to 100.
Bell on Returnbell Switch On

Sounds

  • key-1
  • key-2
  • key-3
  • space
  • backspace
  • return

Turn it on

  1. Turn on Feature Preview in Settings › Advanced, or add feature-preview = true to your config.toml.
  2. Open Settings › Labs and switch Addons on.
  3. Switch Typewriter on. Its settings show up right under it.

Source

The whole addon is this script and its addon.toml.

main.luau27 lines
-- 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)