doNothingWithEnterOnWeb function
ExecutionInstruction
doNothingWithEnterOnWeb({
- required SuperEditorContext editContext,
- required KeyEvent keyEvent,
Implementation
ExecutionInstruction doNothingWithEnterOnWeb({
required SuperEditorContext editContext,
required KeyEvent keyEvent,
}) {
if (keyEvent is! KeyDownEvent && keyEvent is! KeyRepeatEvent) {
return ExecutionInstruction.continueExecution;
}
if (keyEvent.logicalKey != LogicalKeyboardKey.enter && keyEvent.logicalKey != LogicalKeyboardKey.numpadEnter) {
return ExecutionInstruction.continueExecution;
}
if (CurrentPlatform.isWeb) {
// On web, pressing enter generates both a key event and a `TextInputAction.newline` action.
// We handle the newline action and ignore the key event.
// We return blocked so the OS can process it.
return ExecutionInstruction.blocked;
}
return ExecutionInstruction.continueExecution;
}