github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/machine/usb/hid/keyboard/keycode.go (about)

     1  package keyboard
     2  
     3  // Keycode is a package-defined bitmap used to encode the value of a given key.
     4  type Keycode uint16
     5  
     6  // keycode returns the given Unicode codepoint translated to a Keycode sequence.
     7  // Unicode codepoints greater than U+FFFF are unsupported.
     8  //
     9  //go:inline
    10  func keycode(p uint16) Keycode {
    11  	if p < 0x80 {
    12  		return ascii[p]
    13  	} else if p >= 0xA0 && p < 0x0100 {
    14  		return iso88591[p-0xA0]
    15  	} else if uint16(UNICODE20AC) == p {
    16  		return UNICODE20AC.mask()
    17  	}
    18  	return 0
    19  }
    20  
    21  //go:inline
    22  func deadkey(c Keycode) Keycode {
    23  	switch c & deadkeysMask {
    24  	case acuteAccentBits:
    25  		return deadkeyAcuteAccent
    26  	case circumflexBits:
    27  		return deadkeyCircumflex
    28  	case diaeresisBits:
    29  		return deadkeyDiaeresis
    30  	case graveAccentBits:
    31  		return deadkeyGraveAccent
    32  	case tildeBits:
    33  		return deadkeyTilde
    34  	}
    35  	return 0
    36  }
    37  
    38  //go:inline
    39  func (c Keycode) mask() Keycode { return c & keycodeMask }
    40  
    41  //go:inline
    42  func (c Keycode) key() uint8 { return uint8(c & keyMask) }
    43  
    44  //go:inline
    45  func (c Keycode) mod() uint8 {
    46  	var m Keycode
    47  	if 0 != c&shiftMask {
    48  		m |= KeyModifierShift
    49  	}
    50  	if 0 != c&altgrMask {
    51  		m |= KeyModifierRightAlt
    52  	}
    53  	return uint8(m)
    54  }
    55  
    56  //go:inline
    57  func (c Keycode) Shift() Keycode { return c | KeyModifierShift }
    58  
    59  const (
    60  	hidKeyboardKeyCount = 6 // Max number of simultaneous keypresses
    61  	hidKeyboardSysCount = 3
    62  	hidKeyboardConCount = 4
    63  )
    64  
    65  // Keycodes common to all Keyboard layouts
    66  const (
    67  	KeyModifierCtrl       Keycode = 0x01 | 0xE000
    68  	KeyModifierShift      Keycode = 0x02 | 0xE000
    69  	KeyModifierAlt        Keycode = 0x04 | 0xE000
    70  	KeyModifierGUI        Keycode = 0x08 | 0xE000
    71  	KeyModifierLeftCtrl   Keycode = 0x01 | 0xE000
    72  	KeyModifierLeftShift  Keycode = 0x02 | 0xE000
    73  	KeyModifierLeftAlt    Keycode = 0x04 | 0xE000
    74  	KeyModifierLeftGUI    Keycode = 0x08 | 0xE000
    75  	KeyModifierRightCtrl  Keycode = 0x10 | 0xE000
    76  	KeyModifierRightShift Keycode = 0x20 | 0xE000
    77  	KeyModifierRightAlt   Keycode = 0x40 | 0xE000
    78  	KeyModifierRightGUI   Keycode = 0x80 | 0xE000
    79  
    80  	// KeySystemXXX is not supported now
    81  	KeySystemPowerDown Keycode = 0x81 | 0xE200
    82  	KeySystemSleep     Keycode = 0x82 | 0xE200
    83  	KeySystemWakeUp    Keycode = 0x83 | 0xE200
    84  
    85  	KeyMediaPlay        Keycode = 0xB0 | 0xE400
    86  	KeyMediaPause       Keycode = 0xB1 | 0xE400
    87  	KeyMediaRecord      Keycode = 0xB2 | 0xE400
    88  	KeyMediaFastForward Keycode = 0xB3 | 0xE400
    89  	KeyMediaRewind      Keycode = 0xB4 | 0xE400
    90  	KeyMediaNextTrack   Keycode = 0xB5 | 0xE400
    91  	KeyMediaPrevTrack   Keycode = 0xB6 | 0xE400
    92  	KeyMediaStop        Keycode = 0xB7 | 0xE400
    93  	KeyMediaEject       Keycode = 0xB8 | 0xE400
    94  	KeyMediaRandomPlay  Keycode = 0xB9 | 0xE400
    95  	KeyMediaPlayPause   Keycode = 0xCD | 0xE400
    96  	KeyMediaPlaySkip    Keycode = 0xCE | 0xE400
    97  	KeyMediaMute        Keycode = 0xE2 | 0xE400
    98  	KeyMediaVolumeInc   Keycode = 0xE9 | 0xE400
    99  	KeyMediaVolumeDec   Keycode = 0xEA | 0xE400
   100  
   101  	KeyA           Keycode = 4 | 0xF000
   102  	KeyB           Keycode = 5 | 0xF000
   103  	KeyC           Keycode = 6 | 0xF000
   104  	KeyD           Keycode = 7 | 0xF000
   105  	KeyE           Keycode = 8 | 0xF000
   106  	KeyF           Keycode = 9 | 0xF000
   107  	KeyG           Keycode = 10 | 0xF000
   108  	KeyH           Keycode = 11 | 0xF000
   109  	KeyI           Keycode = 12 | 0xF000
   110  	KeyJ           Keycode = 13 | 0xF000
   111  	KeyK           Keycode = 14 | 0xF000
   112  	KeyL           Keycode = 15 | 0xF000
   113  	KeyM           Keycode = 16 | 0xF000
   114  	KeyN           Keycode = 17 | 0xF000
   115  	KeyO           Keycode = 18 | 0xF000
   116  	KeyP           Keycode = 19 | 0xF000
   117  	KeyQ           Keycode = 20 | 0xF000
   118  	KeyR           Keycode = 21 | 0xF000
   119  	KeyS           Keycode = 22 | 0xF000
   120  	KeyT           Keycode = 23 | 0xF000
   121  	KeyU           Keycode = 24 | 0xF000
   122  	KeyV           Keycode = 25 | 0xF000
   123  	KeyW           Keycode = 26 | 0xF000
   124  	KeyX           Keycode = 27 | 0xF000
   125  	KeyY           Keycode = 28 | 0xF000
   126  	KeyZ           Keycode = 29 | 0xF000
   127  	Key1           Keycode = 30 | 0xF000
   128  	Key2           Keycode = 31 | 0xF000
   129  	Key3           Keycode = 32 | 0xF000
   130  	Key4           Keycode = 33 | 0xF000
   131  	Key5           Keycode = 34 | 0xF000
   132  	Key6           Keycode = 35 | 0xF000
   133  	Key7           Keycode = 36 | 0xF000
   134  	Key8           Keycode = 37 | 0xF000
   135  	Key9           Keycode = 38 | 0xF000
   136  	Key0           Keycode = 39 | 0xF000
   137  	KeyEnter       Keycode = 40 | 0xF000
   138  	KeyEsc         Keycode = 41 | 0xF000
   139  	KeyBackspace   Keycode = 42 | 0xF000
   140  	KeyTab         Keycode = 43 | 0xF000
   141  	KeySpace       Keycode = 44 | 0xF000
   142  	KeyMinus       Keycode = 45 | 0xF000
   143  	KeyEqual       Keycode = 46 | 0xF000
   144  	KeyLeftBrace   Keycode = 47 | 0xF000
   145  	KeyRightBrace  Keycode = 48 | 0xF000
   146  	KeyBackslash   Keycode = 49 | 0xF000
   147  	KeyNonUsNum    Keycode = 50 | 0xF000
   148  	KeySemicolon   Keycode = 51 | 0xF000
   149  	KeyQuote       Keycode = 52 | 0xF000
   150  	KeyTilde       Keycode = 53 | 0xF000
   151  	KeyComma       Keycode = 54 | 0xF000
   152  	KeyPeriod      Keycode = 55 | 0xF000
   153  	KeySlash       Keycode = 56 | 0xF000
   154  	KeyCapsLock    Keycode = 57 | 0xF000
   155  	KeyF1          Keycode = 58 | 0xF000
   156  	KeyF2          Keycode = 59 | 0xF000
   157  	KeyF3          Keycode = 60 | 0xF000
   158  	KeyF4          Keycode = 61 | 0xF000
   159  	KeyF5          Keycode = 62 | 0xF000
   160  	KeyF6          Keycode = 63 | 0xF000
   161  	KeyF7          Keycode = 64 | 0xF000
   162  	KeyF8          Keycode = 65 | 0xF000
   163  	KeyF9          Keycode = 66 | 0xF000
   164  	KeyF10         Keycode = 67 | 0xF000
   165  	KeyF11         Keycode = 68 | 0xF000
   166  	KeyF12         Keycode = 69 | 0xF000
   167  	KeyPrintscreen Keycode = 70 | 0xF000
   168  	KeyScrollLock  Keycode = 71 | 0xF000
   169  	KeyPause       Keycode = 72 | 0xF000
   170  	KeyInsert      Keycode = 73 | 0xF000
   171  	KeyHome        Keycode = 74 | 0xF000
   172  	KeyPageUp      Keycode = 75 | 0xF000
   173  	KeyDelete      Keycode = 76 | 0xF000
   174  	KeyEnd         Keycode = 77 | 0xF000
   175  	KeyPageDown    Keycode = 78 | 0xF000
   176  	KeyRight       Keycode = 79 | 0xF000
   177  	KeyLeft        Keycode = 80 | 0xF000
   178  	KeyDown        Keycode = 81 | 0xF000
   179  	KeyUp          Keycode = 82 | 0xF000
   180  	KeyNumLock     Keycode = 83 | 0xF000
   181  	KeypadSlash    Keycode = 84 | 0xF000
   182  	KeypadAsterisk Keycode = 85 | 0xF000
   183  	KeypadMinus    Keycode = 86 | 0xF000
   184  	KeypadPlus     Keycode = 87 | 0xF000
   185  	KeypadEnter    Keycode = 88 | 0xF000
   186  	Keypad1        Keycode = 89 | 0xF000
   187  	Keypad2        Keycode = 90 | 0xF000
   188  	Keypad3        Keycode = 91 | 0xF000
   189  	Keypad4        Keycode = 92 | 0xF000
   190  	Keypad5        Keycode = 93 | 0xF000
   191  	Keypad6        Keycode = 94 | 0xF000
   192  	Keypad7        Keycode = 95 | 0xF000
   193  	Keypad8        Keycode = 96 | 0xF000
   194  	Keypad9        Keycode = 97 | 0xF000
   195  	Keypad0        Keycode = 98 | 0xF000
   196  	KeypadPeriod   Keycode = 99 | 0xF000
   197  	KeyNonUSBS     Keycode = 100 | 0xF000
   198  	KeyMenu        Keycode = 101 | 0xF000
   199  	KeyF13         Keycode = 104 | 0xF000
   200  	KeyF14         Keycode = 105 | 0xF000
   201  	KeyF15         Keycode = 106 | 0xF000
   202  	KeyF16         Keycode = 107 | 0xF000
   203  	KeyF17         Keycode = 108 | 0xF000
   204  	KeyF18         Keycode = 109 | 0xF000
   205  	KeyF19         Keycode = 110 | 0xF000
   206  	KeyF20         Keycode = 111 | 0xF000
   207  	KeyF21         Keycode = 112 | 0xF000
   208  	KeyF22         Keycode = 113 | 0xF000
   209  	KeyF23         Keycode = 114 | 0xF000
   210  	KeyF24         Keycode = 115 | 0xF000
   211  
   212  	KeyUpArrow    Keycode = KeyUp
   213  	KeyDownArrow  Keycode = KeyDown
   214  	KeyLeftArrow  Keycode = KeyLeft
   215  	KeyRightArrow Keycode = KeyRight
   216  	KeyReturn     Keycode = KeyEnter
   217  	KeyLeftCtrl   Keycode = KeyModifierLeftCtrl
   218  	KeyLeftShift  Keycode = KeyModifierLeftShift
   219  	KeyLeftAlt    Keycode = KeyModifierLeftAlt
   220  	KeyLeftGUI    Keycode = KeyModifierLeftGUI
   221  	KeyRightCtrl  Keycode = KeyModifierRightCtrl
   222  	KeyRightShift Keycode = KeyModifierRightShift
   223  	KeyRightAlt   Keycode = KeyModifierRightAlt
   224  	KeyRightGUI   Keycode = KeyModifierRightGUI
   225  )
   226  
   227  // Keycodes for layout US English (0x0904)
   228  const (
   229  	keycodeMask Keycode = 0x07FF
   230  	keyMask     Keycode = 0x003F
   231  
   232  	shiftMask          Keycode = 0x0040
   233  	altgrMask          Keycode = 0x0080
   234  	deadkeysMask       Keycode = 0x0700
   235  	circumflexBits     Keycode = 0x0100
   236  	acuteAccentBits    Keycode = 0x0200
   237  	graveAccentBits    Keycode = 0x0300
   238  	tildeBits          Keycode = 0x0400
   239  	diaeresisBits      Keycode = 0x0500
   240  	deadkeyCircumflex  Keycode = Key6 | shiftMask
   241  	deadkeyAcuteAccent Keycode = KeyQuote
   242  	deadkeyGraveAccent Keycode = KeyTilde
   243  	deadkeyTilde       Keycode = KeyTilde | shiftMask
   244  	deadkeyDiaeresis   Keycode = KeyQuote | shiftMask
   245  
   246  	ASCII00 Keycode = 0            //   0  NUL
   247  	ASCII01 Keycode = 0            //   1  SOH
   248  	ASCII02 Keycode = 0            //   2  STX
   249  	ASCII03 Keycode = 0            //   3  ETX
   250  	ASCII04 Keycode = 0            //   4  EOT
   251  	ASCII05 Keycode = 0            //   5  ENQ
   252  	ASCII06 Keycode = 0            //   6  ACK
   253  	ASCII07 Keycode = 0            //   7  BEL
   254  	ASCII08 Keycode = KeyBackspace //   8  BS
   255  	ASCII09 Keycode = KeyTab       //   9  TAB
   256  	ASCII0A Keycode = KeyEnter     //  10  LF
   257  	ASCII0B Keycode = 0            //  11  VT
   258  	ASCII0C Keycode = 0            //  12  FF
   259  	ASCII0D Keycode = 0            //  13  CR
   260  	ASCII0E Keycode = 0            //  14  SO
   261  	ASCII0F Keycode = 0            //  15  SI
   262  	ASCII10 Keycode = 0            //  16  DEL
   263  	ASCII11 Keycode = 0            //  17  DC1
   264  	ASCII12 Keycode = 0            //  18  DC2
   265  	ASCII13 Keycode = 0            //  19  DC3
   266  	ASCII14 Keycode = 0            //  20  DC4
   267  	ASCII15 Keycode = 0            //  21  NAK
   268  	ASCII16 Keycode = 0            //  22  SYN
   269  	ASCII17 Keycode = 0            //  23  ETB
   270  	ASCII18 Keycode = 0            //  24  CAN
   271  	ASCII19 Keycode = 0            //  25  EM
   272  	ASCII1A Keycode = 0            //  26  SUB
   273  	ASCII1B Keycode = 0            //  27  ESC
   274  	ASCII1C Keycode = 0            //  28  FS
   275  	ASCII1D Keycode = 0            //  29  GS
   276  	ASCII1E Keycode = 0            //  30  RS
   277  	ASCII1F Keycode = 0            //  31  US
   278  
   279  	ASCII20     Keycode = KeySpace                             //  32   SPACE
   280  	ASCII21     Keycode = Key1 | shiftMask                     //  33   !
   281  	ASCII22     Keycode = diaeresisBits | KeySpace             //  34   "
   282  	ASCII23     Keycode = Key3 | shiftMask                     //  35   #
   283  	ASCII24     Keycode = Key4 | shiftMask                     //  36   $
   284  	ASCII25     Keycode = Key5 | shiftMask                     //  37   %
   285  	ASCII26     Keycode = Key7 | shiftMask                     //  38   &
   286  	ASCII27     Keycode = acuteAccentBits | KeySpace           //  39   '
   287  	ASCII28     Keycode = Key9 | shiftMask                     //  40   (
   288  	ASCII29     Keycode = Key0 | shiftMask                     //  41   )
   289  	ASCII2A     Keycode = Key8 | shiftMask                     //  42   *
   290  	ASCII2B     Keycode = KeyEqual | shiftMask                 //  43   +
   291  	ASCII2C     Keycode = KeyComma                             //  44   ,
   292  	ASCII2D     Keycode = KeyMinus                             //  45   -
   293  	ASCII2E     Keycode = KeyPeriod                            //  46   .
   294  	ASCII2F     Keycode = KeySlash                             //  47   /
   295  	ASCII30     Keycode = Key0                                 //  48   0
   296  	ASCII31     Keycode = Key1                                 //  49   1
   297  	ASCII32     Keycode = Key2                                 //  50   2
   298  	ASCII33     Keycode = Key3                                 //  51   3
   299  	ASCII34     Keycode = Key4                                 //  52   4
   300  	ASCII35     Keycode = Key5                                 //  53   5
   301  	ASCII36     Keycode = Key6                                 //  54   6
   302  	ASCII37     Keycode = Key7                                 //  55   7
   303  	ASCII38     Keycode = Key8                                 //  55   8
   304  	ASCII39     Keycode = Key9                                 //  57   9
   305  	ASCII3A     Keycode = KeySemicolon | shiftMask             //  58   :
   306  	ASCII3B     Keycode = KeySemicolon                         //  59   ;
   307  	ASCII3C     Keycode = KeyComma | shiftMask                 //  60   <
   308  	ASCII3D     Keycode = KeyEqual                             //  61   =
   309  	ASCII3E     Keycode = KeyPeriod | shiftMask                //  62   >
   310  	ASCII3F     Keycode = KeySlash | shiftMask                 //  63   ?
   311  	ASCII40     Keycode = Key2 | shiftMask                     //  64   @
   312  	ASCII41     Keycode = KeyA | shiftMask                     //  65   A
   313  	ASCII42     Keycode = KeyB | shiftMask                     //  66   B
   314  	ASCII43     Keycode = KeyC | shiftMask                     //  67   C
   315  	ASCII44     Keycode = KeyD | shiftMask                     //  68   D
   316  	ASCII45     Keycode = KeyE | shiftMask                     //  69   E
   317  	ASCII46     Keycode = KeyF | shiftMask                     //  70   F
   318  	ASCII47     Keycode = KeyG | shiftMask                     //  71   G
   319  	ASCII48     Keycode = KeyH | shiftMask                     //  72   H
   320  	ASCII49     Keycode = KeyI | shiftMask                     //  73   I
   321  	ASCII4A     Keycode = KeyJ | shiftMask                     //  74   J
   322  	ASCII4B     Keycode = KeyK | shiftMask                     //  75   K
   323  	ASCII4C     Keycode = KeyL | shiftMask                     //  76   L
   324  	ASCII4D     Keycode = KeyM | shiftMask                     //  77   M
   325  	ASCII4E     Keycode = KeyN | shiftMask                     //  78   N
   326  	ASCII4F     Keycode = KeyO | shiftMask                     //  79   O
   327  	ASCII50     Keycode = KeyP | shiftMask                     //  80   P
   328  	ASCII51     Keycode = KeyQ | shiftMask                     //  81   Q
   329  	ASCII52     Keycode = KeyR | shiftMask                     //  82   R
   330  	ASCII53     Keycode = KeyS | shiftMask                     //  83   S
   331  	ASCII54     Keycode = KeyT | shiftMask                     //  84   T
   332  	ASCII55     Keycode = KeyU | shiftMask                     //  85   U
   333  	ASCII56     Keycode = KeyV | shiftMask                     //  86   V
   334  	ASCII57     Keycode = KeyW | shiftMask                     //  87   W
   335  	ASCII58     Keycode = KeyX | shiftMask                     //  88   X
   336  	ASCII59     Keycode = KeyY | shiftMask                     //  89   Y
   337  	ASCII5A     Keycode = KeyZ | shiftMask                     //  90   Z
   338  	ASCII5B     Keycode = KeyLeftBrace                         //  91   [
   339  	ASCII5C     Keycode = KeyBackslash                         //  92   \
   340  	ASCII5D     Keycode = KeyRightBrace                        //  93   ]
   341  	ASCII5E     Keycode = circumflexBits | KeySpace            //  94   ^
   342  	ASCII5F     Keycode = KeyMinus | shiftMask                 //  95
   343  	ASCII60     Keycode = graveAccentBits | KeySpace           //  96   `
   344  	ASCII61     Keycode = KeyA                                 //  97   a
   345  	ASCII62     Keycode = KeyB                                 //  98   b
   346  	ASCII63     Keycode = KeyC                                 //  99   c
   347  	ASCII64     Keycode = KeyD                                 // 100   d
   348  	ASCII65     Keycode = KeyE                                 // 101   e
   349  	ASCII66     Keycode = KeyF                                 // 102   f
   350  	ASCII67     Keycode = KeyG                                 // 103   g
   351  	ASCII68     Keycode = KeyH                                 // 104   h
   352  	ASCII69     Keycode = KeyI                                 // 105   i
   353  	ASCII6A     Keycode = KeyJ                                 // 106   j
   354  	ASCII6B     Keycode = KeyK                                 // 107   k
   355  	ASCII6C     Keycode = KeyL                                 // 108   l
   356  	ASCII6D     Keycode = KeyM                                 // 109   m
   357  	ASCII6E     Keycode = KeyN                                 // 110   n
   358  	ASCII6F     Keycode = KeyO                                 // 111   o
   359  	ASCII70     Keycode = KeyP                                 // 112   p
   360  	ASCII71     Keycode = KeyQ                                 // 113   q
   361  	ASCII72     Keycode = KeyR                                 // 114   r
   362  	ASCII73     Keycode = KeyS                                 // 115   s
   363  	ASCII74     Keycode = KeyT                                 // 116   t
   364  	ASCII75     Keycode = KeyU                                 // 117   u
   365  	ASCII76     Keycode = KeyV                                 // 118   v
   366  	ASCII77     Keycode = KeyW                                 // 119   w
   367  	ASCII78     Keycode = KeyX                                 // 120   x
   368  	ASCII79     Keycode = KeyY                                 // 121   y
   369  	ASCII7A     Keycode = KeyZ                                 // 122   z
   370  	ASCII7B     Keycode = KeyLeftBrace | shiftMask             // 123   {
   371  	ASCII7C     Keycode = KeyBackslash | shiftMask             // 124   |
   372  	ASCII7D     Keycode = KeyRightBrace | shiftMask            // 125   }
   373  	ASCII7E     Keycode = tildeBits | KeySpace                 // 126   ~
   374  	ASCII7F     Keycode = KeyBackspace                         // 127   DEL
   375  	ISO88591A0  Keycode = KeySpace                             // 160         Nonbreakng Space
   376  	ISO88591A1  Keycode = Key1 | altgrMask                     // 161   ¡     Inverted Exclamation
   377  	ISO88591A2  Keycode = KeyC | altgrMask | shiftMask         // 162   ¢     Cent SIGN
   378  	ISO88591A3  Keycode = Key4 | altgrMask | shiftMask         // 163   £     Pound Sign
   379  	ISO88591A4  Keycode = Key4 | altgrMask                     // 164   ¤     Currency or Euro Sign
   380  	ISO88591A5  Keycode = KeyMinus | altgrMask                 // 165   ¥     YEN SIGN
   381  	ISO88591A6  Keycode = KeyBackslash | altgrMask | shiftMask // 166   ¦     BROKEN BAR			??
   382  	ISO88591A7  Keycode = KeyS | altgrMask | shiftMask         // 167   §     SECTION SIGN
   383  	ISO88591A8  Keycode = KeyQuote | altgrMask | shiftMask     // 168   ¨     DIAERESIS
   384  	ISO88591A9  Keycode = KeyC | altgrMask                     // 169   ©     COPYRIGHT SIGN
   385  	ISO88591AA  Keycode = 0                                    // 170   ª     FEMININE ORDINAL
   386  	ISO88591AB  Keycode = KeyLeftBrace | altgrMask             // 171   «     LEFT DOUBLE ANGLE QUOTE
   387  	ISO88591AC  Keycode = KeyBackslash | altgrMask             // 172   ¬     NOT SIGN			??
   388  	ISO88591AD  Keycode = 0                                    // 173         SOFT HYPHEN
   389  	ISO88591AE  Keycode = KeyR | altgrMask                     // 174   ®     REGISTERED SIGN
   390  	ISO88591AF  Keycode = 0                                    // 175   ¯     MACRON
   391  	ISO88591B0  Keycode = KeySemicolon | altgrMask | shiftMask // 176   °     DEGREE SIGN
   392  	ISO88591B1  Keycode = 0                                    // 177   ±     PLUS-MINUS SIGN
   393  	ISO88591B2  Keycode = Key2 | altgrMask                     // 178   ²     SUPERSCRIPT TWO
   394  	ISO88591B3  Keycode = Key3 | altgrMask                     // 179   ³     SUPERSCRIPT THREE
   395  	ISO88591B4  Keycode = KeyQuote | altgrMask                 // 180   ´     ACUTE ACCENT
   396  	ISO88591B5  Keycode = KeyM | altgrMask                     // 181   µ     MICRO SIGN
   397  	ISO88591B6  Keycode = KeySemicolon | altgrMask             // 182   ¶     PILCROW SIGN
   398  	ISO88591B7  Keycode = 0                                    // 183   ·     MIDDLE DOT
   399  	ISO88591B8  Keycode = 0                                    // 184   ¸     CEDILLA
   400  	ISO88591B9  Keycode = Key1 | altgrMask | shiftMask         // 185   ¹     SUPERSCRIPT ONE
   401  	ISO88591BA  Keycode = 0                                    // 186   º     MASCULINE ORDINAL
   402  	ISO88591BB  Keycode = KeyRightBrace | altgrMask            // 187   »     RIGHT DOUBLE ANGLE QUOTE
   403  	ISO88591BC  Keycode = Key6 | altgrMask                     // 188   ¼     FRACTION ONE QUARTER
   404  	ISO88591BD  Keycode = Key7 | altgrMask                     // 189   ½     FRACTION ONE HALF
   405  	ISO88591BE  Keycode = Key8 | altgrMask                     // 190   ¾     FRACTION THREE QUARTERS
   406  	ISO88591BF  Keycode = KeySlash | altgrMask                 // 191   ¿     INVERTED QUESTION MARK
   407  	ISO88591C0  Keycode = graveAccentBits | KeyA | shiftMask   // 192   À     A GRAVE
   408  	ISO88591C1  Keycode = KeyA | altgrMask | shiftMask         // 193   Á     A ACUTE
   409  	ISO88591C2  Keycode = circumflexBits | KeyA | shiftMask    // 194   Â     A CIRCUMFLEX
   410  	ISO88591C3  Keycode = tildeBits | KeyA | shiftMask         // 195   Ã     A TILDE
   411  	ISO88591C4  Keycode = KeyQ | altgrMask | shiftMask         // 196   Ä     A DIAERESIS
   412  	ISO88591C5  Keycode = KeyW | altgrMask | shiftMask         // 197   Å     A RING ABOVE
   413  	ISO88591C6  Keycode = KeyZ | altgrMask | shiftMask         // 198   Æ     AE
   414  	ISO88591C7  Keycode = KeyComma | altgrMask | shiftMask     // 199   Ç     C CEDILLA
   415  	ISO88591C8  Keycode = graveAccentBits | KeyE | shiftMask   // 200   È     E GRAVE
   416  	ISO88591C9  Keycode = KeyE | altgrMask | shiftMask         // 201   É     E ACUTE
   417  	ISO88591CA  Keycode = circumflexBits | KeyE | shiftMask    // 202   Ê     E CIRCUMFLEX
   418  	ISO88591CB  Keycode = diaeresisBits | KeyE | shiftMask     // 203   Ë     E DIAERESIS
   419  	ISO88591CC  Keycode = graveAccentBits | KeyI | shiftMask   // 204   Ì     I GRAVE
   420  	ISO88591CD  Keycode = KeyI | altgrMask | shiftMask         // 205   Í     I ACUTE
   421  	ISO88591CE  Keycode = circumflexBits | KeyI | shiftMask    // 206   Î     I CIRCUMFLEX
   422  	ISO88591CF  Keycode = diaeresisBits | KeyI | shiftMask     // 207   Ï     I DIAERESIS
   423  	ISO88591D0  Keycode = KeyD | altgrMask | shiftMask         // 208   Ð     ETH
   424  	ISO88591D1  Keycode = KeyN | altgrMask | shiftMask         // 209   Ñ     N TILDE
   425  	ISO88591D2  Keycode = graveAccentBits | KeyO | shiftMask   // 210   Ò     O GRAVE
   426  	ISO88591D3  Keycode = KeyO | altgrMask | shiftMask         // 211   Ó     O ACUTE
   427  	ISO88591D4  Keycode = circumflexBits | KeyO | shiftMask    // 212   Ô     O CIRCUMFLEX
   428  	ISO88591D5  Keycode = tildeBits | KeyO | shiftMask         // 213   Õ     O TILDE
   429  	ISO88591D6  Keycode = KeyP | altgrMask | shiftMask         // 214   Ö     O DIAERESIS
   430  	ISO88591D7  Keycode = KeyEqual | altgrMask                 // 215   ×     MULTIPLICATION
   431  	ISO88591D8  Keycode = KeyL | altgrMask | shiftMask         // 216   Ø     O STROKE
   432  	ISO88591D9  Keycode = graveAccentBits | KeyU | shiftMask   // 217   Ù     U GRAVE
   433  	ISO88591DA  Keycode = KeyU | altgrMask | shiftMask         // 218   Ú     U ACUTE
   434  	ISO88591DB  Keycode = circumflexBits | KeyU | shiftMask    // 219   Û     U CIRCUMFLEX
   435  	ISO88591DC  Keycode = KeyY | altgrMask | shiftMask         // 220   Ü     U DIAERESIS
   436  	ISO88591DD  Keycode = acuteAccentBits | KeyY | shiftMask   // 221   Ý     Y ACUTE
   437  	ISO88591DE  Keycode = KeyT | altgrMask | shiftMask         // 222   Þ     THORN
   438  	ISO88591DF  Keycode = KeyS | altgrMask                     // 223   ß     SHARP S
   439  	ISO88591E0  Keycode = graveAccentBits | KeyA               // 224   à     a GRAVE
   440  	ISO88591E1  Keycode = KeyA | altgrMask                     // 225   á     a ACUTE
   441  	ISO88591E2  Keycode = circumflexBits | KeyA                // 226   â     a CIRCUMFLEX
   442  	ISO88591E3  Keycode = tildeBits | KeyA                     // 227   ã     a TILDE
   443  	ISO88591E4  Keycode = diaeresisBits | KeyA                 // 228   ä     a DIAERESIS
   444  	ISO88591E5  Keycode = KeyW | altgrMask                     // 229   å     a RING ABOVE
   445  	ISO88591E6  Keycode = KeyZ | altgrMask                     // 230   æ     ae
   446  	ISO88591E7  Keycode = KeyComma | altgrMask                 // 231   ç     c CEDILLA
   447  	ISO88591E8  Keycode = graveAccentBits | KeyE               // 232   è     e GRAVE
   448  	ISO88591E9  Keycode = acuteAccentBits | KeyE               // 233   é     e ACUTE
   449  	ISO88591EA  Keycode = circumflexBits | KeyE                // 234   ê     e CIRCUMFLEX
   450  	ISO88591EB  Keycode = diaeresisBits | KeyE                 // 235   ë     e DIAERESIS
   451  	ISO88591EC  Keycode = graveAccentBits | KeyI               // 236   ì     i GRAVE
   452  	ISO88591ED  Keycode = KeyI | altgrMask                     // 237   í     i ACUTE
   453  	ISO88591EE  Keycode = circumflexBits | KeyI                // 238   î     i CIRCUMFLEX
   454  	ISO88591EF  Keycode = diaeresisBits | KeyI                 // 239   ï     i DIAERESIS
   455  	ISO88591F0  Keycode = KeyD | altgrMask                     // 240   ð     ETH
   456  	ISO88591F1  Keycode = KeyN | altgrMask                     // 241   ñ     n TILDE
   457  	ISO88591F2  Keycode = graveAccentBits | KeyO               // 242   ò     o GRAVE
   458  	ISO88591F3  Keycode = KeyO | altgrMask                     // 243   ó     o ACUTE
   459  	ISO88591F4  Keycode = circumflexBits | KeyO                // 244   ô     o CIRCUMFLEX
   460  	ISO88591F5  Keycode = tildeBits | KeyO                     // 245   õ     o TILDE
   461  	ISO88591F6  Keycode = KeyP | altgrMask                     // 246   ö     o DIAERESIS
   462  	ISO88591F7  Keycode = KeyEqual | altgrMask | shiftMask     // 247   ÷     DIVISION
   463  	ISO88591F8  Keycode = KeyL | altgrMask                     // 248   ø     o STROKE
   464  	ISO88591F9  Keycode = graveAccentBits | KeyU               // 249   ù     u GRAVE
   465  	ISO88591FA  Keycode = KeyU | altgrMask                     // 250   ú     u ACUTE
   466  	ISO88591FB  Keycode = circumflexBits | KeyU                // 251   û     u CIRCUMFLEX
   467  	ISO88591FC  Keycode = KeyY | altgrMask                     // 252   ü     u DIAERESIS
   468  	ISO88591FD  Keycode = acuteAccentBits | KeyY               // 253   ý     y ACUTE
   469  	ISO88591FE  Keycode = KeyT | altgrMask                     // 254   þ     THORN
   470  	ISO88591FF  Keycode = diaeresisBits | KeyY                 // 255   ÿ     y DIAERESIS
   471  	UNICODE20AC Keycode = Key5 | altgrMask                     // 20AC  €     Euro Sign
   472  )
   473  
   474  var ascii = [...]Keycode{
   475  	ASCII00.mask(), ASCII01.mask(), ASCII02.mask(), ASCII03.mask(),
   476  	ASCII04.mask(), ASCII05.mask(), ASCII06.mask(), ASCII07.mask(),
   477  	ASCII08.mask(), ASCII09.mask(), ASCII0A.mask(), ASCII0B.mask(),
   478  	ASCII0C.mask(), ASCII0D.mask(), ASCII0E.mask(), ASCII0F.mask(),
   479  	ASCII10.mask(), ASCII11.mask(), ASCII12.mask(), ASCII13.mask(),
   480  	ASCII14.mask(), ASCII15.mask(), ASCII16.mask(), ASCII17.mask(),
   481  	ASCII18.mask(), ASCII19.mask(), ASCII1A.mask(), ASCII1B.mask(),
   482  	ASCII1C.mask(), ASCII1D.mask(), ASCII1E.mask(), ASCII1F.mask(),
   483  	ASCII20.mask(), ASCII21.mask(), ASCII22.mask(), ASCII23.mask(),
   484  	ASCII24.mask(), ASCII25.mask(), ASCII26.mask(), ASCII27.mask(),
   485  	ASCII28.mask(), ASCII29.mask(), ASCII2A.mask(), ASCII2B.mask(),
   486  	ASCII2C.mask(), ASCII2D.mask(), ASCII2E.mask(), ASCII2F.mask(),
   487  	ASCII30.mask(), ASCII31.mask(), ASCII32.mask(), ASCII33.mask(),
   488  	ASCII34.mask(), ASCII35.mask(), ASCII36.mask(), ASCII37.mask(),
   489  	ASCII38.mask(), ASCII39.mask(), ASCII3A.mask(), ASCII3B.mask(),
   490  	ASCII3C.mask(), ASCII3D.mask(), ASCII3E.mask(), ASCII3F.mask(),
   491  	ASCII40.mask(), ASCII41.mask(), ASCII42.mask(), ASCII43.mask(),
   492  	ASCII44.mask(), ASCII45.mask(), ASCII46.mask(), ASCII47.mask(),
   493  	ASCII48.mask(), ASCII49.mask(), ASCII4A.mask(), ASCII4B.mask(),
   494  	ASCII4C.mask(), ASCII4D.mask(), ASCII4E.mask(), ASCII4F.mask(),
   495  	ASCII50.mask(), ASCII51.mask(), ASCII52.mask(), ASCII53.mask(),
   496  	ASCII54.mask(), ASCII55.mask(), ASCII56.mask(), ASCII57.mask(),
   497  	ASCII58.mask(), ASCII59.mask(), ASCII5A.mask(), ASCII5B.mask(),
   498  	ASCII5C.mask(), ASCII5D.mask(), ASCII5E.mask(), ASCII5F.mask(),
   499  	ASCII60.mask(), ASCII61.mask(), ASCII62.mask(), ASCII63.mask(),
   500  	ASCII64.mask(), ASCII65.mask(), ASCII66.mask(), ASCII67.mask(),
   501  	ASCII68.mask(), ASCII69.mask(), ASCII6A.mask(), ASCII6B.mask(),
   502  	ASCII6C.mask(), ASCII6D.mask(), ASCII6E.mask(), ASCII6F.mask(),
   503  	ASCII70.mask(), ASCII71.mask(), ASCII72.mask(), ASCII73.mask(),
   504  	ASCII74.mask(), ASCII75.mask(), ASCII76.mask(), ASCII77.mask(),
   505  	ASCII78.mask(), ASCII79.mask(), ASCII7A.mask(), ASCII7B.mask(),
   506  	ASCII7C.mask(), ASCII7D.mask(), ASCII7E.mask(), ASCII7F.mask(),
   507  }
   508  
   509  var iso88591 = [...]Keycode{
   510  	ISO88591A0.mask(), ISO88591A1.mask(), ISO88591A2.mask(), ISO88591A3.mask(),
   511  	ISO88591A4.mask(), ISO88591A5.mask(), ISO88591A6.mask(), ISO88591A7.mask(),
   512  	ISO88591A8.mask(), ISO88591A9.mask(), ISO88591AA.mask(), ISO88591AB.mask(),
   513  	ISO88591AC.mask(), ISO88591AD.mask(), ISO88591AE.mask(), ISO88591AF.mask(),
   514  	ISO88591B0.mask(), ISO88591B1.mask(), ISO88591B2.mask(), ISO88591B3.mask(),
   515  	ISO88591B4.mask(), ISO88591B5.mask(), ISO88591B6.mask(), ISO88591B7.mask(),
   516  	ISO88591B8.mask(), ISO88591B9.mask(), ISO88591BA.mask(), ISO88591BB.mask(),
   517  	ISO88591BC.mask(), ISO88591BD.mask(), ISO88591BE.mask(), ISO88591BF.mask(),
   518  	ISO88591C0.mask(), ISO88591C1.mask(), ISO88591C2.mask(), ISO88591C3.mask(),
   519  	ISO88591C4.mask(), ISO88591C5.mask(), ISO88591C6.mask(), ISO88591C7.mask(),
   520  	ISO88591C8.mask(), ISO88591C9.mask(), ISO88591CA.mask(), ISO88591CB.mask(),
   521  	ISO88591CC.mask(), ISO88591CD.mask(), ISO88591CE.mask(), ISO88591CF.mask(),
   522  	ISO88591D0.mask(), ISO88591D1.mask(), ISO88591D2.mask(), ISO88591D3.mask(),
   523  	ISO88591D4.mask(), ISO88591D5.mask(), ISO88591D6.mask(), ISO88591D7.mask(),
   524  	ISO88591D8.mask(), ISO88591D9.mask(), ISO88591DA.mask(), ISO88591DB.mask(),
   525  	ISO88591DC.mask(), ISO88591DD.mask(), ISO88591DE.mask(), ISO88591DF.mask(),
   526  	ISO88591E0.mask(), ISO88591E1.mask(), ISO88591E2.mask(), ISO88591E3.mask(),
   527  	ISO88591E4.mask(), ISO88591E5.mask(), ISO88591E6.mask(), ISO88591E7.mask(),
   528  	ISO88591E8.mask(), ISO88591E9.mask(), ISO88591EA.mask(), ISO88591EB.mask(),
   529  	ISO88591EC.mask(), ISO88591ED.mask(), ISO88591EE.mask(), ISO88591EF.mask(),
   530  	ISO88591F0.mask(), ISO88591F1.mask(), ISO88591F2.mask(), ISO88591F3.mask(),
   531  	ISO88591F4.mask(), ISO88591F5.mask(), ISO88591F6.mask(), ISO88591F7.mask(),
   532  	ISO88591F8.mask(), ISO88591F9.mask(), ISO88591FA.mask(), ISO88591FB.mask(),
   533  	ISO88591FC.mask(), ISO88591FD.mask(), ISO88591FE.mask(), ISO88591FF.mask(),
   534  }