20CAKE20.JS
02-events

Events

6

02-events/04-keyboard.tsx

Keyboard

Example

Official Cake20 View example for keyboard.

export const data = {
  query: "",
};

export const search = () => {
  console.log(data.query);
};

export default () => (
  <input
    class="rounded border p-2"
    bind={data.query}
    onKeydown={(event) => {
      if (event.key === "Enter") search();
      if (event.key === "Escape") data.query = "";
    }}
  />
);