|
121 | 121 | doFilter();
|
122 | 122 | };
|
123 | 123 |
|
124 |
| - var ENTER_CODE = 13; |
125 |
| - var ESCAPE_CODE = 27; |
126 |
| - |
127 | 124 | input.addEventListener('keydown', function (e) {
|
128 |
| - if (e.key) { |
129 |
| - switch (e.key) { |
130 |
| - case Enter: |
131 |
| - onEnter(); |
132 |
| - e.preventDefault(); |
133 |
| - break; |
134 |
| - case Escape: |
135 |
| - case Esc: |
136 |
| - onEscape(); |
137 |
| - e.preventDefault(); |
138 |
| - break; |
139 |
| - } |
140 |
| - } else if (e.keyCode) { |
141 |
| - switch (e.keyCode) { |
142 |
| - case ENTER_CODE: |
143 |
| - onEnter(); |
144 |
| - e.preventDefault(); |
145 |
| - break; |
146 |
| - case ESCAPE_CODE: |
147 |
| - onEscape(); |
148 |
| - e.preventDefault(); |
149 |
| - break; |
150 |
| - } |
| 125 | + switch (e.key) { |
| 126 | + case Enter: |
| 127 | + onEnter(); |
| 128 | + e.preventDefault(); |
| 129 | + break; |
| 130 | + case Escape: |
| 131 | + case Esc: |
| 132 | + onEscape(); |
| 133 | + e.preventDefault(); |
| 134 | + break; |
151 | 135 | }
|
152 | 136 | }, false);
|
153 | 137 |
|
|
350 | 334 | return matchKeyA;
|
351 | 335 | }
|
352 | 336 |
|
| 337 | + // IE specific key |
353 | 338 | var UP = 'Up';
|
354 | 339 | var DOWN = 'Down';
|
355 | 340 | var LEFT = 'Left';
|
|
360 | 345 | var ARROW_LEFT = 'ArrowLeft';
|
361 | 346 | var ARROW_RIGHT = 'ArrowRight';
|
362 | 347 |
|
363 |
| - var ARROW_UP_CODE = 38; |
364 |
| - var ARROW_DOWN_CODE = 40; |
365 |
| - var ARROW_LEFT_CODE = 37; |
366 |
| - var ARROW_RIGHT_CODE = 39; |
367 |
| - |
368 | 348 | var SKIP_TAGS = ['INPUT', 'BUTTON', 'TEXTAREA'];
|
369 | 349 |
|
370 | 350 | var PLATFORM = navigator.platform;
|
|
435 | 415 | return;
|
436 | 416 | }
|
437 | 417 |
|
438 |
| - if (e.key) { |
439 |
| - if (canArrowMove(e)) { |
440 |
| - switch (e.key) { |
441 |
| - case LEFT: |
442 |
| - case ARROW_LEFT: |
443 |
| - if (isToEnd(e)) { |
444 |
| - return getFirstFocusableSibling(pathList); |
445 |
| - } else { |
446 |
| - return getFocusableSibling(pathList, true); |
447 |
| - } |
448 |
| - case RIGHT: |
449 |
| - case ARROW_RIGHT: |
450 |
| - if (isToEnd(e)) { |
451 |
| - return getLastFocusableSibling(pathList); |
452 |
| - } else { |
453 |
| - return getFocusableSibling(pathList, false); |
454 |
| - } |
455 |
| - case UP: |
456 |
| - case ARROW_UP: |
457 |
| - if (isToEnd(e)) { |
458 |
| - return getFirstFocusableSibling(itemList); |
459 |
| - } else { |
460 |
| - return getFocusableSibling(itemList, true); |
461 |
| - } |
462 |
| - case DOWN: |
463 |
| - case ARROW_DOWN: |
464 |
| - if (isToEnd(e)) { |
465 |
| - return getLastFocusableSibling(itemList); |
466 |
| - } else { |
467 |
| - return getFocusableSibling(itemList, false); |
468 |
| - } |
469 |
| - } |
470 |
| - } |
471 |
| - if (!e.ctrlKey && (!e.altKey || IS_MAC_PLATFORM) && !e.metaKey && e.key.length === 1) { |
472 |
| - return lookup(itemList, e.key, e.shiftKey); |
473 |
| - } |
474 |
| - } else if (e.keyCode) { |
475 |
| - if (canArrowMove(e)) { |
476 |
| - switch (e.keyCode) { |
477 |
| - case ARROW_LEFT_CODE: |
478 |
| - if (isToEnd(e)) { |
479 |
| - return getFirstFocusableSibling(pathList); |
480 |
| - } else { |
481 |
| - return getFocusableSibling(pathList, true); |
482 |
| - } |
483 |
| - case ARROW_RIGHT_CODE: |
484 |
| - if (isToEnd(e)) { |
485 |
| - return getLastFocusableSibling(pathList); |
486 |
| - } else { |
487 |
| - return getFocusableSibling(pathList, false); |
488 |
| - } |
489 |
| - case ARROW_UP_CODE: |
490 |
| - if (isToEnd(e)) { |
491 |
| - return getFirstFocusableSibling(itemList); |
492 |
| - } else { |
493 |
| - return getFocusableSibling(itemList, true); |
494 |
| - } |
495 |
| - case ARROW_DOWN_CODE: |
496 |
| - if (isToEnd(e)) { |
497 |
| - return getLastFocusableSibling(itemList); |
498 |
| - } else { |
499 |
| - return getFocusableSibling(itemList, false); |
500 |
| - } |
501 |
| - } |
502 |
| - } |
503 |
| - if (!e.ctrlKey && (!e.altKey || IS_MAC_PLATFORM) && !e.metaKey && e.keyCode >= 32 && e.keyCode <= 126) { |
504 |
| - return lookup(itemList, String.fromCharCode(e.keyCode), e.shiftKey); |
| 418 | + if (canArrowMove(e)) { |
| 419 | + switch (e.key) { |
| 420 | + case LEFT: |
| 421 | + case ARROW_LEFT: |
| 422 | + if (isToEnd(e)) { |
| 423 | + return getFirstFocusableSibling(pathList); |
| 424 | + } else { |
| 425 | + return getFocusableSibling(pathList, true); |
| 426 | + } |
| 427 | + case RIGHT: |
| 428 | + case ARROW_RIGHT: |
| 429 | + if (isToEnd(e)) { |
| 430 | + return getLastFocusableSibling(pathList); |
| 431 | + } else { |
| 432 | + return getFocusableSibling(pathList, false); |
| 433 | + } |
| 434 | + case UP: |
| 435 | + case ARROW_UP: |
| 436 | + if (isToEnd(e)) { |
| 437 | + return getFirstFocusableSibling(itemList); |
| 438 | + } else { |
| 439 | + return getFocusableSibling(itemList, true); |
| 440 | + } |
| 441 | + case DOWN: |
| 442 | + case ARROW_DOWN: |
| 443 | + if (isToEnd(e)) { |
| 444 | + return getLastFocusableSibling(itemList); |
| 445 | + } else { |
| 446 | + return getFocusableSibling(itemList, false); |
| 447 | + } |
505 | 448 | }
|
506 | 449 | }
|
| 450 | + if (!e.ctrlKey && (!e.altKey || IS_MAC_PLATFORM) && !e.metaKey && e.key.length === 1) { |
| 451 | + return lookup(itemList, e.key, e.shiftKey); |
| 452 | + } |
507 | 453 | }
|
508 | 454 |
|
509 | 455 | document.addEventListener('keydown', function (e) {
|
|
0 commit comments