Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

477 B
Raw Blame
import type { KeyboardEvent } from 'react';

/**
 * What a non-native button needs to work from the keyboard: it takes focus, and
 * Enter or Space activates it the way a click does.
 */
export const activateProps = (onActivate: () => void) => ({
  onKeyDown: (event: Pick<KeyboardEvent, 'key' | 'preventDefault'>) => {
    if (event.key !== 'Enter' && event.key !== ' ') return;
    event.preventDefault();
    onActivate();
  },
  role: 'button' as const,
  tabIndex: 0,
});