switch command with ctrl on mac and ios.

This commit is contained in:
Miroslav Šedivý 2021-03-31 20:12:59 +02:00
parent 3d7478ba71
commit 3b88b5c623

View File

@ -48,12 +48,10 @@
'bFPoAjrev5EfwZQNfoKbju/u1ri/PvfgKYGMl+K2I7b8U7wA5wpgC/AgAA///Yyif1MZXzRQAAAABJRU5ErkJggg==) 4 4, crosshair' 'bFPoAjrev5EfwZQNfoKbju/u1ri/PvfgKYGMl+K2I7b8U7wA5wpgC/AgAA///Yyif1MZXzRQAAAABJRU5ErkJggg==) 4 4, crosshair'
const KeyTable = { const KeyTable = {
XK_Super_L: 0xffeb, // Left super XK_Meta_L: 0xffe7, // Left meta
XK_Super_R: 0xffec, // Right super XK_Meta_R: 0xffe8, // Right meta
XK_Alt_L: 0xffe9, // Left alt XK_Control_L: 0xffe3, // Left control
XK_Alt_R: 0xffea, // Right alt XK_Control_R: 0xffe4, // Right control
XK_Mode_switch: 0xff7e, // Character set switch
XK_ISO_Level3_Shift: 0xfe03, // AltGr
} }
@Component({ @Component({
@ -104,20 +102,13 @@
const isMac = navigator && navigator.platform.match(/^mac/i) const isMac = navigator && navigator.platform.match(/^mac/i)
const isiOS = navigator && navigator.platform.match(/ipad|iphone|ipod/i) const isiOS = navigator && navigator.platform.match(/ipad|iphone|ipod/i)
// Alt behaves more like AltGraph on macOS, so shuffle the // switch command with ctrl on mac and ios
// keys around a bit to make things more sane for the remote
// server. This method is used by RealVNC and TigerVNC (and
// possibly others).
if (isMac || isiOS) { if (isMac || isiOS) {
switch (key) { switch (key) {
case KeyTable.XK_Super_L: case KeyTable.XK_Meta_L:
return KeyTable.XK_Alt_L return KeyTable.XK_Control_L
case KeyTable.XK_Super_R: case KeyTable.XK_Meta_R:
return KeyTable.XK_Super_L return KeyTable.XK_Control_R
case KeyTable.XK_Alt_L:
return KeyTable.XK_Mode_switch
case KeyTable.XK_Alt_R:
return KeyTable.XK_ISO_Level3_Shift
} }
} }