diff --git a/packages/thebe/src/codemirror.ts b/packages/thebe/src/codemirror.ts index 97a745ba..ffe9821d 100644 --- a/packages/thebe/src/codemirror.ts +++ b/packages/thebe/src/codemirror.ts @@ -32,6 +32,7 @@ interface RequiredCodeMirrorConfig { extraKeys: { 'Shift-Enter': () => void; 'Ctrl-Space': () => void; + 'Esc': () => void; }; } @@ -62,6 +63,10 @@ export function setupCodemirror( const ref: { cm?: any } = { cm: undefined }; + function unFocus() { + ref.cm?.display.input.blur() + } + function codeCompletion() { console.debug(`thebe:codemirror:codeCompletion`); const code = ref.cm?.getValue(); @@ -116,7 +121,8 @@ export function setupCodemirror( extraKeys: { 'Shift-Enter': execute, 'Ctrl-Space': codeCompletion, - }, + 'Esc': unFocus, + }, }; const codeMirrorConfig = Object.assign(