(key: Key)
| 245 | ]) |
| 246 | |
| 247 | function handleEnter(key: Key) { |
| 248 | if ( |
| 249 | multiline && |
| 250 | cursor.offset > 0 && |
| 251 | cursor.text[cursor.offset - 1] === '\\' |
| 252 | ) { |
| 253 | // Track that the user has used backslash+return |
| 254 | markBackslashReturnUsed() |
| 255 | return cursor.backspace().insert('\n') |
| 256 | } |
| 257 | // Meta+Enter or Shift+Enter inserts a newline |
| 258 | if (key.meta || key.shift) { |
| 259 | return cursor.insert('\n') |
| 260 | } |
| 261 | // Apple Terminal doesn't support custom Shift+Enter keybindings, |
| 262 | // so we use native macOS modifier detection to check if Shift is held |
| 263 | if (env.terminal === 'Apple_Terminal' && isModifierPressed('shift')) { |
| 264 | return cursor.insert('\n') |
| 265 | } |
| 266 | onSubmit?.(originalValue) |
| 267 | } |
| 268 | |
| 269 | function upOrHistoryUp() { |
| 270 | if (disableCursorMovementForUpDownKeys) { |
no test coverage detected