Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d33fce1c
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d33fce1c
编写于
5月 19, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify key code to string mappings
上级
87cfa195
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
157 addition
and
195 deletion
+157
-195
src/vs/base/common/keyCodes.ts
src/vs/base/common/keyCodes.ts
+157
-195
未找到文件。
src/vs/base/common/keyCodes.ts
浏览文件 @
d33fce1c
...
...
@@ -200,222 +200,184 @@ export const enum KeyCode {
MAX_VALUE
}
export
interface
IReverseMap
{
[
str
:
string
]:
KeyCode
;
}
class
KeyCodeStrMap
{
export
class
Mapping
{
private
_keyCodeToStr
:
string
[];
private
_strToKeyCode
:
{
[
str
:
string
]:
KeyCode
;
};
_fromKeyCode
:
string
[];
_toKeyCode
:
IReverseMap
;
constructor
()
{
this
.
_keyCodeToStr
=
[];
this
.
_strToKeyCode
=
Object
.
create
(
null
);
}
constructor
(
fromKeyCode
:
string
[],
toKeyCode
:
IReverseMap
)
{
this
.
_
fromKeyCode
=
fromKeyCode
;
this
.
_
toKeyCode
=
toK
eyCode
;
define
(
keyCode
:
KeyCode
,
str
:
string
):
void
{
this
.
_
keyCodeToStr
[
keyCode
]
=
str
;
this
.
_
strToKeyCode
[
str
.
toLowerCase
()]
=
k
eyCode
;
}
fromKeyCode
(
keyCode
:
KeyCode
):
string
{
return
this
.
_
fromKeyCode
[
keyCode
];
return
this
.
_
keyCodeToStr
[
keyCode
];
}
toKeyCode
(
str
:
string
):
KeyCode
{
if
(
this
.
_toKeyCode
.
hasOwnProperty
(
str
))
{
return
this
.
_toKeyCode
[
str
];
}
return
KeyCode
.
Unknown
;
return
this
.
_strToKeyCode
[
str
.
toLowerCase
()]
||
KeyCode
.
Unknown
;
}
}
function
createMapping
(
fill1
:
(
map
:
string
[])
=>
void
,
fill2
:
(
reverseMap
:
IReverseMap
)
=>
void
):
Mapping
{
let
MAP
:
string
[]
=
[]
;
fill1
(
MAP
);
const
ui
=
new
KeyCodeStrMap
();
const
usUserSettings
=
new
KeyCodeStrMap
()
;
const
generalUserSettings
=
new
KeyCodeStrMap
(
);
let
REVERSE_MAP
:
IReverseMap
=
{};
for
(
let
i
=
0
,
len
=
MAP
.
length
;
i
<
len
;
i
++
)
{
if
(
!
MAP
[
i
])
{
continue
;
}
REVERSE_MAP
[
MAP
[
i
]]
=
i
;
}
fill2
(
REVERSE_MAP
);
(
function
()
{
let
FINAL_REVERSE_MAP
:
IReverseMap
=
{};
for
(
let
entry
in
REVERSE_MAP
)
{
if
(
REVERSE_MAP
.
hasOwnProperty
(
entry
))
{
FINAL_REVERSE_MAP
[
entry
]
=
REVERSE_MAP
[
entry
];
FINAL_REVERSE_MAP
[
entry
.
toLowerCase
()]
=
REVERSE_MAP
[
entry
];
}
function
define
(
keyCode
:
KeyCode
,
uiLabel
:
string
,
usUserSettingsLabel
:
string
=
uiLabel
,
generalUserSettingsLabel
:
string
=
usUserSettingsLabel
):
void
{
ui
.
define
(
keyCode
,
uiLabel
);
usUserSettings
.
define
(
keyCode
,
usUserSettingsLabel
);
generalUserSettings
.
define
(
keyCode
,
generalUserSettingsLabel
);
}
return
new
Mapping
(
MAP
,
FINAL_REVERSE_MAP
);
}
let
STRING
=
createMapping
((
TO_STRING_MAP
)
=>
{
TO_STRING_MAP
[
KeyCode
.
Unknown
]
=
'
unknown
'
;
TO_STRING_MAP
[
KeyCode
.
Backspace
]
=
'
Backspace
'
;
TO_STRING_MAP
[
KeyCode
.
Tab
]
=
'
Tab
'
;
TO_STRING_MAP
[
KeyCode
.
Enter
]
=
'
Enter
'
;
TO_STRING_MAP
[
KeyCode
.
Shift
]
=
'
Shift
'
;
TO_STRING_MAP
[
KeyCode
.
Ctrl
]
=
'
Ctrl
'
;
TO_STRING_MAP
[
KeyCode
.
Alt
]
=
'
Alt
'
;
TO_STRING_MAP
[
KeyCode
.
PauseBreak
]
=
'
PauseBreak
'
;
TO_STRING_MAP
[
KeyCode
.
CapsLock
]
=
'
CapsLock
'
;
TO_STRING_MAP
[
KeyCode
.
Escape
]
=
'
Escape
'
;
TO_STRING_MAP
[
KeyCode
.
Space
]
=
'
Space
'
;
TO_STRING_MAP
[
KeyCode
.
PageUp
]
=
'
PageUp
'
;
TO_STRING_MAP
[
KeyCode
.
PageDown
]
=
'
PageDown
'
;
TO_STRING_MAP
[
KeyCode
.
End
]
=
'
End
'
;
TO_STRING_MAP
[
KeyCode
.
Home
]
=
'
Home
'
;
TO_STRING_MAP
[
KeyCode
.
LeftArrow
]
=
'
LeftArrow
'
;
TO_STRING_MAP
[
KeyCode
.
UpArrow
]
=
'
UpArrow
'
;
TO_STRING_MAP
[
KeyCode
.
RightArrow
]
=
'
RightArrow
'
;
TO_STRING_MAP
[
KeyCode
.
DownArrow
]
=
'
DownArrow
'
;
TO_STRING_MAP
[
KeyCode
.
Insert
]
=
'
Insert
'
;
TO_STRING_MAP
[
KeyCode
.
Delete
]
=
'
Delete
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_0
]
=
'
0
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_1
]
=
'
1
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_2
]
=
'
2
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_3
]
=
'
3
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_4
]
=
'
4
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_5
]
=
'
5
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_6
]
=
'
6
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_7
]
=
'
7
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_8
]
=
'
8
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_9
]
=
'
9
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_A
]
=
'
A
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_B
]
=
'
B
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_C
]
=
'
C
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_D
]
=
'
D
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_E
]
=
'
E
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_F
]
=
'
F
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_G
]
=
'
G
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_H
]
=
'
H
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_I
]
=
'
I
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_J
]
=
'
J
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_K
]
=
'
K
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_L
]
=
'
L
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_M
]
=
'
M
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_N
]
=
'
N
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_O
]
=
'
O
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_P
]
=
'
P
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_Q
]
=
'
Q
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_R
]
=
'
R
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_S
]
=
'
S
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_T
]
=
'
T
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_U
]
=
'
U
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_V
]
=
'
V
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_W
]
=
'
W
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_X
]
=
'
X
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_Y
]
=
'
Y
'
;
TO_STRING_MAP
[
KeyCode
.
KEY_Z
]
=
'
Z
'
;
TO_STRING_MAP
[
KeyCode
.
Meta
]
=
'
Meta
'
;
TO_STRING_MAP
[
KeyCode
.
ContextMenu
]
=
'
ContextMenu
'
;
TO_STRING_MAP
[
KeyCode
.
F1
]
=
'
F1
'
;
TO_STRING_MAP
[
KeyCode
.
F2
]
=
'
F2
'
;
TO_STRING_MAP
[
KeyCode
.
F3
]
=
'
F3
'
;
TO_STRING_MAP
[
KeyCode
.
F4
]
=
'
F4
'
;
TO_STRING_MAP
[
KeyCode
.
F5
]
=
'
F5
'
;
TO_STRING_MAP
[
KeyCode
.
F6
]
=
'
F6
'
;
TO_STRING_MAP
[
KeyCode
.
F7
]
=
'
F7
'
;
TO_STRING_MAP
[
KeyCode
.
F8
]
=
'
F8
'
;
TO_STRING_MAP
[
KeyCode
.
F9
]
=
'
F9
'
;
TO_STRING_MAP
[
KeyCode
.
F10
]
=
'
F10
'
;
TO_STRING_MAP
[
KeyCode
.
F11
]
=
'
F11
'
;
TO_STRING_MAP
[
KeyCode
.
F12
]
=
'
F12
'
;
TO_STRING_MAP
[
KeyCode
.
F13
]
=
'
F13
'
;
TO_STRING_MAP
[
KeyCode
.
F14
]
=
'
F14
'
;
TO_STRING_MAP
[
KeyCode
.
F15
]
=
'
F15
'
;
TO_STRING_MAP
[
KeyCode
.
F16
]
=
'
F16
'
;
TO_STRING_MAP
[
KeyCode
.
F17
]
=
'
F17
'
;
TO_STRING_MAP
[
KeyCode
.
F18
]
=
'
F18
'
;
TO_STRING_MAP
[
KeyCode
.
F19
]
=
'
F19
'
;
TO_STRING_MAP
[
KeyCode
.
NumLock
]
=
'
NumLock
'
;
TO_STRING_MAP
[
KeyCode
.
ScrollLock
]
=
'
ScrollLock
'
;
TO_STRING_MAP
[
KeyCode
.
US_SEMICOLON
]
=
'
;
'
;
TO_STRING_MAP
[
KeyCode
.
US_EQUAL
]
=
'
=
'
;
TO_STRING_MAP
[
KeyCode
.
US_COMMA
]
=
'
,
'
;
TO_STRING_MAP
[
KeyCode
.
US_MINUS
]
=
'
-
'
;
TO_STRING_MAP
[
KeyCode
.
US_DOT
]
=
'
.
'
;
TO_STRING_MAP
[
KeyCode
.
US_SLASH
]
=
'
/
'
;
TO_STRING_MAP
[
KeyCode
.
US_BACKTICK
]
=
'
`
'
;
TO_STRING_MAP
[
KeyCode
.
ABNT_C1
]
=
'
ABNT_C1
'
;
TO_STRING_MAP
[
KeyCode
.
ABNT_C2
]
=
'
ABNT_C2
'
;
TO_STRING_MAP
[
KeyCode
.
US_OPEN_SQUARE_BRACKET
]
=
'
[
'
;
TO_STRING_MAP
[
KeyCode
.
US_BACKSLASH
]
=
'
\\
'
;
TO_STRING_MAP
[
KeyCode
.
US_CLOSE_SQUARE_BRACKET
]
=
'
]
'
;
TO_STRING_MAP
[
KeyCode
.
US_QUOTE
]
=
'
\'
'
;
TO_STRING_MAP
[
KeyCode
.
OEM_8
]
=
'
OEM_8
'
;
TO_STRING_MAP
[
KeyCode
.
OEM_102
]
=
'
OEM_102
'
;
TO_STRING_MAP
[
KeyCode
.
NUMPAD_0
]
=
'
NumPad0
'
;
TO_STRING_MAP
[
KeyCode
.
NUMPAD_1
]
=
'
NumPad1
'
;
TO_STRING_MAP
[
KeyCode
.
NUMPAD_2
]
=
'
NumPad2
'
;
TO_STRING_MAP
[
KeyCode
.
NUMPAD_3
]
=
'
NumPad3
'
;
TO_STRING_MAP
[
KeyCode
.
NUMPAD_4
]
=
'
NumPad4
'
;
TO_STRING_MAP
[
KeyCode
.
NUMPAD_5
]
=
'
NumPad5
'
;
TO_STRING_MAP
[
KeyCode
.
NUMPAD_6
]
=
'
NumPad6
'
;
TO_STRING_MAP
[
KeyCode
.
NUMPAD_7
]
=
'
NumPad7
'
;
TO_STRING_MAP
[
KeyCode
.
NUMPAD_8
]
=
'
NumPad8
'
;
TO_STRING_MAP
[
KeyCode
.
NUMPAD_9
]
=
'
NumPad9
'
;
TO_STRING_MAP
[
KeyCode
.
NUMPAD_MULTIPLY
]
=
'
NumPad_Multiply
'
;
TO_STRING_MAP
[
KeyCode
.
NUMPAD_ADD
]
=
'
NumPad_Add
'
;
TO_STRING_MAP
[
KeyCode
.
NUMPAD_SEPARATOR
]
=
'
NumPad_Separator
'
;
TO_STRING_MAP
[
KeyCode
.
NUMPAD_SUBTRACT
]
=
'
NumPad_Subtract
'
;
TO_STRING_MAP
[
KeyCode
.
NUMPAD_DECIMAL
]
=
'
NumPad_Decimal
'
;
TO_STRING_MAP
[
KeyCode
.
NUMPAD_DIVIDE
]
=
'
NumPad_Divide
'
;
// for (let i = 0; i < KeyCode.MAX_VALUE; i++) {
// if (!TO_STRING_MAP[i]) {
// console.warn('Missing string representation for ' + KeyCode[i]);
// }
// }
},
(
FROM_STRING_MAP
)
=>
{
FROM_STRING_MAP
[
'
\r
'
]
=
KeyCode
.
Enter
;
});
export
let
USER_SETTINGS
=
createMapping
((
TO_USER_SETTINGS_MAP
)
=>
{
for
(
let
i
=
0
,
len
=
STRING
.
_fromKeyCode
.
length
;
i
<
len
;
i
++
)
{
TO_USER_SETTINGS_MAP
[
i
]
=
STRING
.
_fromKeyCode
[
i
];
define
(
KeyCode
.
Unknown
,
'
unknown
'
);
define
(
KeyCode
.
Backspace
,
'
Backspace
'
);
define
(
KeyCode
.
Tab
,
'
Tab
'
);
define
(
KeyCode
.
Enter
,
'
Enter
'
);
define
(
KeyCode
.
Shift
,
'
Shift
'
);
define
(
KeyCode
.
Ctrl
,
'
Ctrl
'
);
define
(
KeyCode
.
Alt
,
'
Alt
'
);
define
(
KeyCode
.
PauseBreak
,
'
PauseBreak
'
);
define
(
KeyCode
.
CapsLock
,
'
CapsLock
'
);
define
(
KeyCode
.
Escape
,
'
Escape
'
);
define
(
KeyCode
.
Space
,
'
Space
'
);
define
(
KeyCode
.
PageUp
,
'
PageUp
'
);
define
(
KeyCode
.
PageDown
,
'
PageDown
'
);
define
(
KeyCode
.
End
,
'
End
'
);
define
(
KeyCode
.
Home
,
'
Home
'
);
define
(
KeyCode
.
LeftArrow
,
'
LeftArrow
'
,
'
Left
'
);
define
(
KeyCode
.
UpArrow
,
'
UpArrow
'
,
'
Up
'
);
define
(
KeyCode
.
RightArrow
,
'
RightArrow
'
,
'
Right
'
);
define
(
KeyCode
.
DownArrow
,
'
DownArrow
'
,
'
Down
'
);
define
(
KeyCode
.
Insert
,
'
Insert
'
);
define
(
KeyCode
.
Delete
,
'
Delete
'
);
define
(
KeyCode
.
KEY_0
,
'
0
'
);
define
(
KeyCode
.
KEY_1
,
'
1
'
);
define
(
KeyCode
.
KEY_2
,
'
2
'
);
define
(
KeyCode
.
KEY_3
,
'
3
'
);
define
(
KeyCode
.
KEY_4
,
'
4
'
);
define
(
KeyCode
.
KEY_5
,
'
5
'
);
define
(
KeyCode
.
KEY_6
,
'
6
'
);
define
(
KeyCode
.
KEY_7
,
'
7
'
);
define
(
KeyCode
.
KEY_8
,
'
8
'
);
define
(
KeyCode
.
KEY_9
,
'
9
'
);
define
(
KeyCode
.
KEY_A
,
'
A
'
);
define
(
KeyCode
.
KEY_B
,
'
B
'
);
define
(
KeyCode
.
KEY_C
,
'
C
'
);
define
(
KeyCode
.
KEY_D
,
'
D
'
);
define
(
KeyCode
.
KEY_E
,
'
E
'
);
define
(
KeyCode
.
KEY_F
,
'
F
'
);
define
(
KeyCode
.
KEY_G
,
'
G
'
);
define
(
KeyCode
.
KEY_H
,
'
H
'
);
define
(
KeyCode
.
KEY_I
,
'
I
'
);
define
(
KeyCode
.
KEY_J
,
'
J
'
);
define
(
KeyCode
.
KEY_K
,
'
K
'
);
define
(
KeyCode
.
KEY_L
,
'
L
'
);
define
(
KeyCode
.
KEY_M
,
'
M
'
);
define
(
KeyCode
.
KEY_N
,
'
N
'
);
define
(
KeyCode
.
KEY_O
,
'
O
'
);
define
(
KeyCode
.
KEY_P
,
'
P
'
);
define
(
KeyCode
.
KEY_Q
,
'
Q
'
);
define
(
KeyCode
.
KEY_R
,
'
R
'
);
define
(
KeyCode
.
KEY_S
,
'
S
'
);
define
(
KeyCode
.
KEY_T
,
'
T
'
);
define
(
KeyCode
.
KEY_U
,
'
U
'
);
define
(
KeyCode
.
KEY_V
,
'
V
'
);
define
(
KeyCode
.
KEY_W
,
'
W
'
);
define
(
KeyCode
.
KEY_X
,
'
X
'
);
define
(
KeyCode
.
KEY_Y
,
'
Y
'
);
define
(
KeyCode
.
KEY_Z
,
'
Z
'
);
define
(
KeyCode
.
Meta
,
'
Meta
'
);
define
(
KeyCode
.
ContextMenu
,
'
ContextMenu
'
);
define
(
KeyCode
.
F1
,
'
F1
'
);
define
(
KeyCode
.
F2
,
'
F2
'
);
define
(
KeyCode
.
F3
,
'
F3
'
);
define
(
KeyCode
.
F4
,
'
F4
'
);
define
(
KeyCode
.
F5
,
'
F5
'
);
define
(
KeyCode
.
F6
,
'
F6
'
);
define
(
KeyCode
.
F7
,
'
F7
'
);
define
(
KeyCode
.
F8
,
'
F8
'
);
define
(
KeyCode
.
F9
,
'
F9
'
);
define
(
KeyCode
.
F10
,
'
F10
'
);
define
(
KeyCode
.
F11
,
'
F11
'
);
define
(
KeyCode
.
F12
,
'
F12
'
);
define
(
KeyCode
.
F13
,
'
F13
'
);
define
(
KeyCode
.
F14
,
'
F14
'
);
define
(
KeyCode
.
F15
,
'
F15
'
);
define
(
KeyCode
.
F16
,
'
F16
'
);
define
(
KeyCode
.
F17
,
'
F17
'
);
define
(
KeyCode
.
F18
,
'
F18
'
);
define
(
KeyCode
.
F19
,
'
F19
'
);
define
(
KeyCode
.
NumLock
,
'
NumLock
'
);
define
(
KeyCode
.
ScrollLock
,
'
ScrollLock
'
);
define
(
KeyCode
.
US_SEMICOLON
,
'
;
'
,
'
;
'
,
'
OEM_1
'
);
define
(
KeyCode
.
US_EQUAL
,
'
=
'
,
'
=
'
,
'
OEM_PLUS
'
);
define
(
KeyCode
.
US_COMMA
,
'
,
'
,
'
,
'
,
'
OEM_COMMA
'
);
define
(
KeyCode
.
US_MINUS
,
'
-
'
,
'
-
'
,
'
OEM_MINUS
'
);
define
(
KeyCode
.
US_DOT
,
'
.
'
,
'
.
'
,
'
OEM_PERIOD
'
);
define
(
KeyCode
.
US_SLASH
,
'
/
'
,
'
/
'
,
'
OEM_2
'
);
define
(
KeyCode
.
US_BACKTICK
,
'
`
'
,
'
`
'
,
'
OEM_3
'
);
define
(
KeyCode
.
ABNT_C1
,
'
ABNT_C1
'
);
define
(
KeyCode
.
ABNT_C2
,
'
ABNT_C2
'
);
define
(
KeyCode
.
US_OPEN_SQUARE_BRACKET
,
'
[
'
,
'
[
'
,
'
OEM_4
'
);
define
(
KeyCode
.
US_BACKSLASH
,
'
\\
'
,
'
\\
'
,
'
OEM_5
'
);
define
(
KeyCode
.
US_CLOSE_SQUARE_BRACKET
,
'
]
'
,
'
]
'
,
'
OEM_6
'
);
define
(
KeyCode
.
US_QUOTE
,
'
\'
'
,
'
\'
'
,
'
OEM_7
'
);
define
(
KeyCode
.
OEM_8
,
'
OEM_8
'
);
define
(
KeyCode
.
OEM_102
,
'
OEM_102
'
);
define
(
KeyCode
.
NUMPAD_0
,
'
NumPad0
'
);
define
(
KeyCode
.
NUMPAD_1
,
'
NumPad1
'
);
define
(
KeyCode
.
NUMPAD_2
,
'
NumPad2
'
);
define
(
KeyCode
.
NUMPAD_3
,
'
NumPad3
'
);
define
(
KeyCode
.
NUMPAD_4
,
'
NumPad4
'
);
define
(
KeyCode
.
NUMPAD_5
,
'
NumPad5
'
);
define
(
KeyCode
.
NUMPAD_6
,
'
NumPad6
'
);
define
(
KeyCode
.
NUMPAD_7
,
'
NumPad7
'
);
define
(
KeyCode
.
NUMPAD_8
,
'
NumPad8
'
);
define
(
KeyCode
.
NUMPAD_9
,
'
NumPad9
'
);
define
(
KeyCode
.
NUMPAD_MULTIPLY
,
'
NumPad_Multiply
'
);
define
(
KeyCode
.
NUMPAD_ADD
,
'
NumPad_Add
'
);
define
(
KeyCode
.
NUMPAD_SEPARATOR
,
'
NumPad_Separator
'
);
define
(
KeyCode
.
NUMPAD_SUBTRACT
,
'
NumPad_Subtract
'
);
define
(
KeyCode
.
NUMPAD_DECIMAL
,
'
NumPad_Decimal
'
);
define
(
KeyCode
.
NUMPAD_DIVIDE
,
'
NumPad_Divide
'
);
})();
export
const
USER_SETTINGS
=
{
fromKeyCode
:
(
keyCode
:
KeyCode
)
=>
{
return
usUserSettings
.
fromKeyCode
(
keyCode
);
},
toKeyCode
:
(
str
:
string
)
=>
{
return
usUserSettings
.
toKeyCode
(
str
)
||
generalUserSettings
.
toKeyCode
(
str
);
}
TO_USER_SETTINGS_MAP
[
KeyCode
.
LeftArrow
]
=
'
Left
'
;
TO_USER_SETTINGS_MAP
[
KeyCode
.
UpArrow
]
=
'
Up
'
;
TO_USER_SETTINGS_MAP
[
KeyCode
.
RightArrow
]
=
'
Right
'
;
TO_USER_SETTINGS_MAP
[
KeyCode
.
DownArrow
]
=
'
Down
'
;
},
(
FROM_USER_SETTINGS_MAP
)
=>
{
FROM_USER_SETTINGS_MAP
[
'
OEM_1
'
]
=
KeyCode
.
US_SEMICOLON
;
FROM_USER_SETTINGS_MAP
[
'
OEM_PLUS
'
]
=
KeyCode
.
US_EQUAL
;
FROM_USER_SETTINGS_MAP
[
'
OEM_COMMA
'
]
=
KeyCode
.
US_COMMA
;
FROM_USER_SETTINGS_MAP
[
'
OEM_MINUS
'
]
=
KeyCode
.
US_MINUS
;
FROM_USER_SETTINGS_MAP
[
'
OEM_PERIOD
'
]
=
KeyCode
.
US_DOT
;
FROM_USER_SETTINGS_MAP
[
'
OEM_2
'
]
=
KeyCode
.
US_SLASH
;
FROM_USER_SETTINGS_MAP
[
'
OEM_3
'
]
=
KeyCode
.
US_BACKTICK
;
FROM_USER_SETTINGS_MAP
[
'
ABNT_C1
'
]
=
KeyCode
.
ABNT_C1
;
FROM_USER_SETTINGS_MAP
[
'
ABNT_C2
'
]
=
KeyCode
.
ABNT_C2
;
FROM_USER_SETTINGS_MAP
[
'
OEM_4
'
]
=
KeyCode
.
US_OPEN_SQUARE_BRACKET
;
FROM_USER_SETTINGS_MAP
[
'
OEM_5
'
]
=
KeyCode
.
US_BACKSLASH
;
FROM_USER_SETTINGS_MAP
[
'
OEM_6
'
]
=
KeyCode
.
US_CLOSE_SQUARE_BRACKET
;
FROM_USER_SETTINGS_MAP
[
'
OEM_7
'
]
=
KeyCode
.
US_QUOTE
;
FROM_USER_SETTINGS_MAP
[
'
OEM_8
'
]
=
KeyCode
.
OEM_8
;
FROM_USER_SETTINGS_MAP
[
'
OEM_102
'
]
=
KeyCode
.
OEM_102
;
});
};
export
namespace
KeyCodeUtils
{
export
function
toString
(
key
:
KeyCode
):
string
{
return
STRING
.
fromKeyCode
(
key
);
export
function
toString
(
keyCode
:
KeyCode
):
string
{
return
ui
.
fromKeyCode
(
keyCode
);
// return STRING.fromKeyCode(keyCode);
}
export
function
fromString
(
key
:
string
):
KeyCode
{
return
STRING
.
toKeyCode
(
key
);
return
ui
.
toKeyCode
(
key
);
// return STRING.toKeyCode(key);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录