Commit
add ctrl+enter shortcut to start a debate
commit
64a4cd2
1 changed file with +16 and −3
modified src/components/debate/new-debate.tsx +16 −3
| @@ -160,13 +160,26 @@export function NewDebate() { | ||
| 160 | 160 | <textarea |
| 161 | 161 | value={question} |
| 162 | 162 | onChange={(e) => setQuestion(e.target.value)} |
| 163 | + onKeyDown={(e) => { | |
| 164 | + if (e.key === 'Enter' && (e.metaKey || e.ctrlKey) && canStart) { | |
| 165 | + e.preventDefault(); | |
| 166 | + launch(); | |
| 167 | + } | |
| 168 | + }} | |
| 163 | 169 | placeholder={EXAMPLE} |
| 164 | 170 | rows={3} |
| 171 | + aria-label="Debate question" | |
| 165 | 172 | className="flex w-full resize-none rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring" |
| 166 | 173 | /> |
| 167 | - <button className="text-xs text-primary hover:underline" onClick={() => setQuestion(EXAMPLE)}> | |
| 168 | - Use an example question | |
| 169 | - </button> | |
| 174 | + <div className="flex items-center justify-between"> | |
| 175 | + <button className="text-xs text-primary hover:underline" onClick={() => setQuestion(EXAMPLE)}> | |
| 176 | + Use an example question | |
| 177 | + </button> | |
| 178 | + <span className="text-xs text-muted-foreground"> | |
| 179 | + <kbd className="rounded border bg-muted px-1 font-mono text-[10px]">Ctrl</kbd> +{' '} | |
| 180 | + <kbd className="rounded border bg-muted px-1 font-mono text-[10px]">Enter</kbd> to start | |
| 181 | + </span> | |
| 182 | + </div> | |
| 170 | 183 | </CardContent> |
| 171 | 184 | </Card> |
| 172 | 185 |