Skip to content

Instantly share code, notes, and snippets.

@ancestral
Created July 6, 2012 04:33
Show Gist options
  • Star 43 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save ancestral/3058100 to your computer and use it in GitHub Desktop.
Save ancestral/3058100 to your computer and use it in GitHub Desktop.
ASCII keyboard map for JavaScript keycodes (Mac)
/*
* JavaScript Keyboard Map (Mac layout)
*
*
* esc—— F1——— F2——— F3——— F4——— F5——— F6——— F7——— F8——— F9——— F10—— F11—— F12—— F13—————+
* | 27 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | ??? |
* ` ——— 1———— 2———— 3———— 4———— 5———— 6———— 7———— 8———— 9———— 0———— - ——— = ——— delete——+
* | 192 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
* tab———— Q———— W———— E———— R———— T———— Y———— U———— I———— O———— P———— [ ——— ] ——— \ ————+
* | 9 | 81 | 87 | 69 | 82 | 84 | 89 | 85 | 73 | 79 | 80 | 219 | 221 | 220 |
* caps————— A———— S———— D———— F———— G———— H———— J———— K———— L———— ; ——— ' ——— return————+
* | 20 | 65 | 83 | 68 | 70 | 71 | 72 | 74 | 75 | 76 | 186 | 222 | 13 |
* shift—————— Z———— X———— C———— V———— B———— N———— M———— , ——— . ——— / ——— shift—————————+
* | 16 | 90 | 88 | 67 | 86 | 66 | 78 | 77 | 188 | 190 | 191 | 16 |
* fn—— ctrl opt— command space—————————————————————————— command opt——+—————up————+—————+
* | | 17 | 18 | 91 | 32 | 93 | 18 | | 38 | |
* +————+————+————+———————+———————————————————————————————+———————+————left——down——right—+
* | 37 | 40 | 39 |
* +—————+—————+—————+
*/
@wujunze
Copy link

wujunze commented May 9, 2017

Thanks

@CalicoCatalyst
Copy link

CalicoCatalyst commented Nov 9, 2017

This but easier to read

/* 
 *  JavaScript Keyboard Map (Mac layout)
 *
 *
 *                esc—— F1——— F2——— F3——— F4——— F5——— F6——— F7——— F8——— F9——— F10—— F11—— F12—— F13—————+
 *              |  27 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 |  ???  |
 *
 *           ` ——— 1———— 2———— 3———— 4———— 5———— 6———— 7———— 8———— 9———— 0———— - ——— = ——— delete——+
 *              | 192 |  49 |  50 |  51 |  52 |  53 |  54 |  55 |  56 |  57 |  58 |  59 |  60 |   61  |
 *
 *                 tab———— Q———— W———— E———— R———— T———— Y———— U———— I———— O———— P———— [ ——— ] ——— \ ————+
 *              |   9   |  81 |  87 |  69 |  82 |  84 |  89 |  85 |  73 |  79 |  80 | 219 | 221 | 220 |
 *
 *                  caps————— A———— S———— D———— F———— G———— H———— J———— K———— L———— ; ——— ' ——— return————+
 *              |    20   |  65 |  83 |  68 |  70 |  71 |  72 |  74 |  75 |  76 | 186 | 222 |   13    |
 * 
 *                shift—————— Z———— X———— C———— V———— B———— N———— M———— , ——— . ——— / ——— shift—————————+
 *              |    16     |  90 |  88 |  67 |  86 |  66 |  78 |  77 | 188 | 190 | 191 |     16      |
 *
 *                fn—— ctrl opt— command space—————————————————————————— command opt——+—————up————+—————+  
 *              |    | 17 | 18 |   91  |            32                 |   93  | 18 |     |  38 |     |
 *
 *                                                                       ———————+————left——down——right—+
 *                                                                                  |  37 |  40 |  39 |
 */

@CGS-Jack-Bashford
Copy link

I found a small problem - 0 is actually 48, not 58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment