UNPKG

@kui-shell/core

Version:

An Electron-based shell for cloud-native development

55 lines (54 loc) 1.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.keys = exports.isCursorMovement = exports.Codes = void 0; /* * Copyright 2017 The Kubernetes Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ const keys = { ENTER: 13, BACKSPACE: 127, ESCAPE: 27, TAB: 9, LEFT_ARROW: 37, RIGHT_ARROW: 39, A: 65, B: 66, C: 67, D: 68, E: 69, F: 70, U: 85, UP: 38, P: 80, DOWN: 40, K: 75, L: 76, N: 78, R: 82, T: 'T'.charCodeAt(0), PAGEUP: 33, PAGEDOWN: 34, END: 35, HOME: 36 }; exports.Codes = exports.keys = keys; /** does the given keycode correspond to a cursor movement? */ const isCursorMovement = evt => { const code = evt.key; return evt.ctrlKey && (code === 'a' || code === 'e' || code === 'f' || code === 'b') || code === 'ArrowLeft' || code === 'ArrowRight'; }; exports.isCursorMovement = isCursorMovement;