export function bindInput({ canvas, onEscape, onAction }) {
  window.addEventListener('keydown', event => {
    if (event.key === 'Escape') onEscape();
  });

  const handlePointer = event => {
    const rect = canvas.getBoundingClientRect();
    onAction({
      x: event.clientX - rect.left,
      y: event.clientY - rect.top
    });
  };

  canvas.addEventListener('pointerdown', handlePointer);
}
