bitty installation snippets examples documentation q&a

snippets

map a key to a signal

The 'a' key has been pressed 0 times.
  • Keys can be mapped to signals with b.mapKey()

html

<div>The 'a' key has been pressed <span data-r="pressed">0</span> times.</div>

javascript

export const b = { init: "mapA" };

let count = 0;

export function mapA() {
  b.mapKey("a", "pressed");
}

export function pressed(_, __, el) {
  count += 1;
  el.innerHTML = count;
}