remix-nlux
Version:
Remix IDE NLUX integration. Remix IDE is the leading IDE for building and deploying smart contracts on Ethereum. NLUX is a JavaScript and React library for building conversational AI experiences.
25 lines (20 loc) • 751 B
text/typescript
import {KeyboardEvent} from 'react';
export const isSubmitShortcutKey = (
event: KeyboardEvent,
submitShortcut?: 'Enter' | 'CommandEnter',
): boolean => {
if (!submitShortcut || submitShortcut === 'Enter') {
const isEnter = event.key === 'Enter' && !event.nativeEvent.isComposing;
const aModifierKeyIsPressed = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
return isEnter && !aModifierKeyIsPressed;
}
if (submitShortcut === 'CommandEnter') {
const isCommandEnter = event.key === 'Enter' && (
event.getModifierState('Control') || event.getModifierState('Meta')
);
if (isCommandEnter) {
return true;
}
}
return false;
};