in packages/roosterjs-react-emoji/lib/plugins/EmojiPlugin.tsx [92:117]
public onPluginEvent(event: PluginEvent): void {
const domEvent = event as PluginDomEvent;
const keyboardEvent = domEvent.rawEvent as KeyboardEvent;
if (event.eventType === PluginEventType.KeyDown) {
this._eventHandledOnKeyDown = false;
if (this._isSuggesting) {
this._onKeyDownSuggestingDomEvent(domEvent);
} else if (keyboardEvent.which === KeyCodes.backspace && this._canUndoEmoji) {
// If KeyDown is backspace and canUndoEmoji, call editor undo
this._editor.undo();
this._handleEventOnKeyDown(domEvent);
this._canUndoEmoji = false;
}
} else if (event.eventType === PluginEventType.KeyUp && !this._isModifierKey(keyboardEvent.key)) {
if (this._isSuggesting) {
this._onKeyUpSuggestingDomEvent(domEvent);
} else {
this._onKeyUpDomEvent(domEvent);
}
} else if (event.eventType === PluginEventType.MouseUp) {
// If MouseUp, the emoji cannot be undone
this._canUndoEmoji = false;
this._setIsSuggesting(false);
}
}