1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/open-hand-choerodon-ui

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Это зеркальный репозиторий, синхронизируется ежедневно с исходного репозитория.
Клонировать/Скачать
KeyCode.tsx 7.6 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
HughHzWu Отправлено 6 лет назад 951db21
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
export default class KeyCode {
/**
* MAC_ENTER
*/
static MAC_ENTER = 3;
/**
* BACKSPACE
*/
static BACKSPACE = 8;
/**
* TAB
*/
static TAB = 9;
/**
* NUMLOCK on FF/Safari Mac
*/
static NUM_CENTER = 12; // NUMLOCK on FF/Safari Mac
/**
* ENTER
*/
static ENTER = 13;
/**
* SHIFT
*/
static SHIFT = 16;
/**
* CTRL
*/
static CTRL = 17;
/**
* ALT
*/
static ALT = 18;
/**
* PAUSE
*/
static PAUSE = 19;
/**
* CAPS_LOCK
*/
static CAPS_LOCK = 20;
/**
* ESC
*/
static ESC = 27;
/**
* SPACE
*/
static SPACE = 32;
/**
* PAGE_UP
*/
static PAGE_UP = 33; // also NUM_NORTH_EAST
/**
* PAGE_DOWN
*/
static PAGE_DOWN = 34; // also NUM_SOUTH_EAST
/**
* END
*/
static END = 35; // also NUM_SOUTH_WEST
/**
* HOME
*/
static HOME = 36; // also NUM_NORTH_WEST
/**
* LEFT
*/
static LEFT = 37; // also NUM_WEST
/**
* UP
*/
static UP = 38; // also NUM_NORTH
/**
* RIGHT
*/
static RIGHT = 39; // also NUM_EAST
/**
* DOWN
*/
static DOWN = 40; // also NUM_SOUTH
/**
* PRINT_SCREEN
*/
static PRINT_SCREEN = 44;
/**
* INSERT
*/
static INSERT = 45; // also NUM_INSERT
/**
* DELETE
*/
static DELETE = 46; // also NUM_DELETE
/**
* ZERO
*/
static ZERO = 48;
/**
* ONE
*/
static ONE = 49;
/**
* TWO
*/
static TWO = 50;
/**
* THREE
*/
static THREE = 51;
/**
* FOUR
*/
static FOUR = 52;
/**
* FIVE
*/
static FIVE = 53;
/**
* SIX
*/
static SIX = 54;
/**
* SEVEN
*/
static SEVEN = 55;
/**
* EIGHT
*/
static EIGHT = 56;
/**
* NINE
*/
static NINE = 57;
/**
* QUESTION_MARK
*/
static QUESTION_MARK = 63; // needs localization
/**
* A
*/
static A = 65;
/**
* B
*/
static B = 66;
/**
* C
*/
static C = 67;
/**
* D
*/
static D = 68;
/**
* E
*/
static E = 69;
/**
* F
*/
static F = 70;
/**
* G
*/
static G = 71;
/**
* H
*/
static H = 72;
/**
* I
*/
static I = 73;
/**
* J
*/
static J = 74;
/**
* K
*/
static K = 75;
/**
* L
*/
static L = 76;
/**
* M
*/
static M = 77;
/**
* N
*/
static N = 78;
/**
* O
*/
static O = 79;
/**
* P
*/
static P = 80;
/**
* Q
*/
static Q = 81;
/**
* R
*/
static R = 82;
/**
* S
*/
static S = 83;
/**
* T
*/
static T = 84;
/**
* U
*/
static U = 85;
/**
* V
*/
static V = 86;
/**
* W
*/
static W = 87;
/**
* X
*/
static X = 88;
/**
* Y
*/
static Y = 89;
/**
* Z
*/
static Z = 90;
/**
* META
*/
static META = 91; // WIN_KEY_LEFT
/**
* WIN_KEY_RIGHT
*/
static WIN_KEY_RIGHT = 92;
/**
* CONTEXT_MENU
*/
static CONTEXT_MENU = 93;
/**
* NUM_ZERO
*/
static NUM_ZERO = 96;
/**
* NUM_ONE
*/
static NUM_ONE = 97;
/**
* NUM_TWO
*/
static NUM_TWO = 98;
/**
* NUM_THREE
*/
static NUM_THREE = 99;
/**
* NUM_FOUR
*/
static NUM_FOUR = 100;
/**
* NUM_FIVE
*/
static NUM_FIVE = 101;
/**
* NUM_SIX
*/
static NUM_SIX = 102;
/**
* NUM_SEVEN
*/
static NUM_SEVEN = 103;
/**
* NUM_EIGHT
*/
static NUM_EIGHT = 104;
/**
* NUM_NINE
*/
static NUM_NINE = 105;
/**
* NUM_MULTIPLY
*/
static NUM_MULTIPLY = 106;
/**
* NUM_PLUS
*/
static NUM_PLUS = 107;
/**
* NUM_MINUS
*/
static NUM_MINUS = 109;
/**
* NUM_PERIOD
*/
static NUM_PERIOD = 110;
/**
* NUM_DIVISION
*/
static NUM_DIVISION = 111;
/**
* F1
*/
static F1 = 112;
/**
* F2
*/
static F2 = 113;
/**
* F3
*/
static F3 = 114;
/**
* F4
*/
static F4 = 115;
/**
* F5
*/
static F5 = 116;
/**
* F6
*/
static F6 = 117;
/**
* F7
*/
static F7 = 118;
/**
* F8
*/
static F8 = 119;
/**
* F9
*/
static F9 = 120;
/**
* F10
*/
static F10 = 121;
/**
* F11
*/
static F11 = 122;
/**
* F12
*/
static F12 = 123;
/**
* NUMLOCK
*/
static NUMLOCK = 144;
/**
* SEMICOLON
*/
static SEMICOLON = 186; // needs localization
/**
* DASH
*/
static DASH = 189; // needs localization
/**
* EQUALS
*/
static EQUALS = 187; // needs localization
/**
* COMMA
*/
static COMMA = 188; // needs localization
/**
* PERIOD
*/
static PERIOD = 190; // needs localization
/**
* SLASH
*/
static SLASH = 191; // needs localization
/**
* APOSTROPHE
*/
static APOSTROPHE = 192; // needs localization
/**
* SINGLE_QUOTE
*/
static SINGLE_QUOTE = 222; // needs localization
/**
* OPEN_SQUARE_BRACKET
*/
static OPEN_SQUARE_BRACKET = 219; // needs localization
/**
* BACKSLASH
*/
static BACKSLASH = 220; // needs localization
/**
* CLOSE_SQUARE_BRACKET
*/
static CLOSE_SQUARE_BRACKET = 221; // needs localization
/**
* WIN_KEY
*/
static WIN_KEY = 224;
/**
* MAC_FF_META
*/
static MAC_FF_META = 224; // Firefox (Gecko) fires this for the meta key instead of 91
/**
* WIN_IME
*/
static WIN_IME = 229;
/*
whether text and modified key is entered at the same time.
*/
static isTextModifyingKeyEvent(e) {
const keyCode = e.keyCode;
if (
(e.altKey && !e.ctrlKey) ||
e.metaKey ||
// Function keys don't generate text
(keyCode >= KeyCode.F1 && keyCode <= KeyCode.F12)
) {
return false;
}
// The following keys are quite harmless, even in combination with
// CTRL, ALT or SHIFT.
switch (keyCode) {
case KeyCode.ALT:
case KeyCode.CAPS_LOCK:
case KeyCode.CONTEXT_MENU:
case KeyCode.CTRL:
case KeyCode.DOWN:
case KeyCode.END:
case KeyCode.ESC:
case KeyCode.HOME:
case KeyCode.INSERT:
case KeyCode.LEFT:
case KeyCode.MAC_FF_META:
case KeyCode.META:
case KeyCode.NUMLOCK:
case KeyCode.NUM_CENTER:
case KeyCode.PAGE_DOWN:
case KeyCode.PAGE_UP:
case KeyCode.PAUSE:
case KeyCode.PRINT_SCREEN:
case KeyCode.RIGHT:
case KeyCode.SHIFT:
case KeyCode.UP:
case KeyCode.WIN_KEY:
case KeyCode.WIN_KEY_RIGHT:
return false;
default:
return true;
}
}
/*
whether character is entered.
*/
static isCharacterKey(keyCode) {
if (keyCode >= KeyCode.ZERO && keyCode <= KeyCode.NINE) {
return true;
}
if (keyCode >= KeyCode.NUM_ZERO && keyCode <= KeyCode.NUM_MULTIPLY) {
return true;
}
if (keyCode >= KeyCode.A && keyCode <= KeyCode.Z) {
return true;
}
// Safari sends zero key code for non-latin characters.
if (
keyCode === 0 &&
typeof window !== 'undefined' &&
window.navigator.userAgent.indexOf('WebKit') !== -1
) {
return true;
}
switch (keyCode) {
case KeyCode.SPACE:
case KeyCode.QUESTION_MARK:
case KeyCode.NUM_PLUS:
case KeyCode.NUM_MINUS:
case KeyCode.NUM_PERIOD:
case KeyCode.NUM_DIVISION:
case KeyCode.SEMICOLON:
case KeyCode.DASH:
case KeyCode.EQUALS:
case KeyCode.COMMA:
case KeyCode.PERIOD:
case KeyCode.SLASH:
case KeyCode.APOSTROPHE:
case KeyCode.SINGLE_QUOTE:
case KeyCode.OPEN_SQUARE_BRACKET:
case KeyCode.BACKSLASH:
case KeyCode.CLOSE_SQUARE_BRACKET:
return true;
default:
return false;
}
}
}

Комментарий ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://gitlife.ru/oschina-mirror/open-hand-choerodon-ui.git
git@gitlife.ru:oschina-mirror/open-hand-choerodon-ui.git
oschina-mirror
open-hand-choerodon-ui
open-hand-choerodon-ui
master