File tree 1 file changed +61
-31
lines changed 1 file changed +61
-31
lines changed Original file line number Diff line number Diff line change @@ -1172,33 +1172,23 @@ export namespace CommandRegistry {
1172
1172
* Format a keystroke for display on the local system.
1173
1173
*/
1174
1174
export function formatKeystroke ( keystroke : string ) : string {
1175
- let mods = '' ;
1175
+ let mods = [ ] ;
1176
+ let separator = Platform . IS_MAC ? " " : "+" ;
1176
1177
let parts = parseKeystroke ( keystroke ) ;
1177
- if ( Platform . IS_MAC ) {
1178
- if ( parts . ctrl ) {
1179
- mods += '\u2303 ' ;
1180
- }
1181
- if ( parts . alt ) {
1182
- mods += '\u2325 ' ;
1183
- }
1184
- if ( parts . shift ) {
1185
- mods += '\u21E7 ' ;
1186
- }
1187
- if ( parts . cmd ) {
1188
- mods += '\u2318 ' ;
1189
- }
1190
- } else {
1191
- if ( parts . ctrl ) {
1192
- mods += 'Ctrl+' ;
1193
- }
1194
- if ( parts . alt ) {
1195
- mods += 'Alt+' ;
1196
- }
1197
- if ( parts . shift ) {
1198
- mods += 'Shift+' ;
1199
- }
1178
+ if ( parts . ctrl ) {
1179
+ mods . push ( 'Ctrl' ) ;
1200
1180
}
1201
- return mods + parts . key ;
1181
+ if ( parts . alt ) {
1182
+ mods . push ( 'Alt' ) ;
1183
+ }
1184
+ if ( parts . shift ) {
1185
+ mods . push ( 'Shift' ) ;
1186
+ }
1187
+ if ( Platform . IS_MAC && parts . cmd ) {
1188
+ mods . push ( 'Cmd' ) ;
1189
+ }
1190
+ mods . push ( parts . key ) ;
1191
+ return mods . map ( Private . formatKey ) . join ( separator ) ;
1202
1192
}
1203
1193
1204
1194
/**
@@ -1228,20 +1218,21 @@ export namespace CommandRegistry {
1228
1218
if ( ! key || layout . isModifierKey ( key ) ) {
1229
1219
return '' ;
1230
1220
}
1231
- let mods = '' ;
1221
+ let mods = [ ] ;
1232
1222
if ( event . ctrlKey ) {
1233
- mods += 'Ctrl ' ;
1223
+ mods . push ( 'Ctrl' )
1234
1224
}
1235
1225
if ( event . altKey ) {
1236
- mods += 'Alt ' ;
1226
+ mods . push ( 'Alt' )
1237
1227
}
1238
1228
if ( event . shiftKey ) {
1239
- mods += 'Shift ' ;
1229
+ mods . push ( 'Shift' )
1240
1230
}
1241
1231
if ( event . metaKey && Platform . IS_MAC ) {
1242
- mods += 'Cmd ' ;
1232
+ mods . push ( 'Cmd' )
1243
1233
}
1244
- return mods + key ;
1234
+ mods . push ( key ) ;
1235
+ return mods . join ( " " ) ;
1245
1236
}
1246
1237
}
1247
1238
@@ -1438,6 +1429,45 @@ namespace Private {
1438
1429
event . target ! . dispatchEvent ( cloneKeyboardEvent ( event ) ) ;
1439
1430
}
1440
1431
1432
+ export function formatKey ( key : string ) : string {
1433
+ if ( Platform . IS_MAC ) {
1434
+ return MAC_DISPLAY . hasOwnProperty ( key ) ? MAC_DISPLAY [ key ] : key ;
1435
+ } else {
1436
+ return WIN_DISPLAY . hasOwnProperty ( key ) ? WIN_DISPLAY [ key ] : key ;
1437
+ }
1438
+ }
1439
+
1440
+ const MAC_DISPLAY : { [ key : string ] : string } = {
1441
+ Backspace : '⌫' ,
1442
+ Tab : '⇥' ,
1443
+ Enter : '↩' ,
1444
+ Shift : '⇧' ,
1445
+ Ctrl : '⌃' ,
1446
+ Alt : '⌥' ,
1447
+ Escape : '⎋' ,
1448
+ PageUp : '⇞' ,
1449
+ PageDown : '⇟' ,
1450
+ End : '↘' ,
1451
+ Home : '↖' ,
1452
+ ArrowLeft : '←' ,
1453
+ ArrowUp : '↑' ,
1454
+ ArrowRight : '→' ,
1455
+ ArrowDown : '↓' ,
1456
+ Delete : '⌦' ,
1457
+ Cmd : '⌘'
1458
+ } ;
1459
+
1460
+ const WIN_DISPLAY : { [ key : string ] : string } = {
1461
+ Escape : 'Esc' ,
1462
+ PageUp : 'Page Up' ,
1463
+ PageDown : 'Page Down' ,
1464
+ ArrowLeft : 'Left' ,
1465
+ ArrowUp : 'Right' ,
1466
+ ArrowRight : 'Up' ,
1467
+ ArrowDown : 'Down' ,
1468
+ Delete : 'Del'
1469
+ } ;
1470
+
1441
1471
/**
1442
1472
* A singleton empty string function.
1443
1473
*/
You can’t perform that action at this time.
0 commit comments