| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 -- Copyright 2013 The Chromium Authors. All rights reserved. | 2 -- Copyright 2013 The Chromium Authors. All rights reserved. |
| 3 -- Use of this source code is governed by a BSD-style license that can be | 3 -- Use of this source code is governed by a BSD-style license that can be |
| 4 -- found in the LICENSE file. | 4 -- found in the LICENSE file. |
| 5 --> | 5 --> |
| 6 | 6 |
| 7 <polymer-element name="kb-keyboard" on-key-over="keyOver" on-key-up="keyUp" | 7 <polymer-element name="kb-keyboard" on-key-over="keyOver" on-key-up="keyUp" |
| 8 on-key-down="keyDown" on-key-longpress="keyLongpress" on-pointerup="up" | 8 on-key-down="keyDown" on-key-longpress="keyLongpress" on-pointerup="up" |
| 9 on-pointerdown="down" on-enable-sel="enableSel" | 9 on-pointerdown="down" on-enable-sel="enableSel" |
| 10 on-enable-dbl="enableDbl" on-key-out="keyOut" | 10 on-enable-dbl="enableDbl" on-key-out="keyOut" |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 default: | 362 default: |
| 363 // Notify shift key. | 363 // Notify shift key. |
| 364 if (this.shift) | 364 if (this.shift) |
| 365 this.shift.onNonControlKeyDown(); | 365 this.shift.onNonControlKeyDown(); |
| 366 break; | 366 break; |
| 367 } | 367 } |
| 368 if(this.changeKeyset(detail)) | 368 if(this.changeKeyset(detail)) |
| 369 return; | 369 return; |
| 370 if (detail.repeat) { | 370 if (detail.repeat) { |
| 371 this.keyTyped(detail); | 371 this.keyTyped(detail); |
| 372 this.onNonControlKeyTyped(); |
| 372 repeatKey.key = this.lastPressedKey; | 373 repeatKey.key = this.lastPressedKey; |
| 373 var self = this; | 374 var self = this; |
| 374 repeatKey.timer = setTimeout(function() { | 375 repeatKey.timer = setTimeout(function() { |
| 375 repeatKey.timer = undefined; | 376 repeatKey.timer = undefined; |
| 376 repeatKey.interval = setInterval(function() { | 377 repeatKey.interval = setInterval(function() { |
| 377 self.keyTyped(detail); | 378 self.keyTyped(detail); |
| 378 }, REPEAT_INTERVAL_MSEC); | 379 }, REPEAT_INTERVAL_MSEC); |
| 379 }, Math.max(0, REPEAT_DELAY_MSEC - REPEAT_INTERVAL_MSEC)); | 380 }, Math.max(0, REPEAT_DELAY_MSEC - REPEAT_INTERVAL_MSEC)); |
| 380 } | 381 } |
| 381 }, | 382 }, |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 case '.': | 540 case '.': |
| 540 case '?': | 541 case '?': |
| 541 case '!': | 542 case '!': |
| 542 enterUpperOnSpace = true; | 543 enterUpperOnSpace = true; |
| 543 break; | 544 break; |
| 544 default: | 545 default: |
| 545 break; | 546 break; |
| 546 } | 547 } |
| 547 if(!this.keyTyped(detail)) | 548 if(!this.keyTyped(detail)) |
| 548 insertText(char); | 549 insertText(char); |
| 549 if (this.ctrl) | 550 this.onNonControlKeyTyped(); |
| 550 this.ctrl.onNonControlKeyUp(); | |
| 551 if (this.alt) | |
| 552 this.alt.onNonControlKeyUp(); | |
| 553 this.classList.remove('ctrl-active'); | |
| 554 this.classList.remove('alt-active'); | |
| 555 }, | 551 }, |
| 556 | 552 |
| 557 /* | 553 /* |
| 558 * Handles key-longpress event that is sent by kb-key-base. | 554 * Handles key-longpress event that is sent by kb-key-base. |
| 559 * @param {CustomEvent} event The key-longpress event dispatched by | 555 * @param {CustomEvent} event The key-longpress event dispatched by |
| 560 * kb-key-base. | 556 * kb-key-base. |
| 561 * @param {Object} detail The detail of pressed key. | 557 * @param {Object} detail The detail of pressed key. |
| 562 */ | 558 */ |
| 563 keyLongpress: function(event, detail) { | 559 keyLongpress: function(event, detail) { |
| 564 // If the gesture is long press, remove the pointermove listener. | 560 // If the gesture is long press, remove the pointermove listener. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 HTMLImports.importer.load(document, function() { | 601 HTMLImports.importer.load(document, function() { |
| 606 HTMLImports.parser.parseLink(link); | 602 HTMLImports.parser.parseLink(link); |
| 607 self.layoutChanged(); | 603 self.layoutChanged(); |
| 608 }); | 604 }); |
| 609 } | 605 } |
| 610 } | 606 } |
| 611 } | 607 } |
| 612 }, | 608 }, |
| 613 | 609 |
| 614 /** | 610 /** |
| 611 * Notifies the modifier keys that a non-control key was typed. This |
| 612 * lets them reset sticky behaviour. A non-control key is defined as |
| 613 * any key that is not Control, Alt, or Shift. |
| 614 */ |
| 615 onNonControlKeyTyped: function() { |
| 616 if (this.shift) |
| 617 this.shift.onNonControlKeyTyped(); |
| 618 if (this.ctrl) |
| 619 this.ctrl.onNonControlKeyTyped(); |
| 620 if (this.alt) |
| 621 this.alt.onNonControlKeyTyped(); |
| 622 this.classList.remove('ctrl-active'); |
| 623 this.classList.remove('alt-active'); |
| 624 }, |
| 625 |
| 626 /** |
| 615 * Indicate if the keyboard is ready for user input. | 627 * Indicate if the keyboard is ready for user input. |
| 616 * @type {boolean} | 628 * @type {boolean} |
| 617 */ | 629 */ |
| 618 get initialized() { | 630 get initialized() { |
| 619 return this.isReady; | 631 return this.isReady; |
| 620 }, | 632 }, |
| 621 | 633 |
| 622 /** | 634 /** |
| 623 * Id for the active keyset. | 635 * Id for the active keyset. |
| 624 * @type {string} | 636 * @type {string} |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 }, | 668 }, |
| 657 | 669 |
| 658 /** | 670 /** |
| 659 * Generates fabricated key events to simulate typing on a | 671 * Generates fabricated key events to simulate typing on a |
| 660 * physical keyboard. | 672 * physical keyboard. |
| 661 * @param {Object} detail Attributes of the key being typed. | 673 * @param {Object} detail Attributes of the key being typed. |
| 662 * @return {boolean} Whether the key type succeeded. | 674 * @return {boolean} Whether the key type succeeded. |
| 663 */ | 675 */ |
| 664 keyTyped: function(detail) { | 676 keyTyped: function(detail) { |
| 665 var builder = this.$.keyCodeMetadata; | 677 var builder = this.$.keyCodeMetadata; |
| 678 if (this.shift) |
| 679 detail.shiftModifier = this.shift.isActive(); |
| 666 if (this.ctrl) | 680 if (this.ctrl) |
| 667 detail.controlModifier = this.ctrl.isActive(); | 681 detail.controlModifier = this.ctrl.isActive(); |
| 668 if (this.alt) | 682 if (this.alt) |
| 669 detail.altModifier = this.alt.isActive(); | 683 detail.altModifier = this.alt.isActive(); |
| 670 var downEvent = builder.createVirtualKeyEvent(detail, "keydown"); | 684 var downEvent = builder.createVirtualKeyEvent(detail, "keydown"); |
| 671 if (downEvent) { | 685 if (downEvent) { |
| 672 sendKeyEvent(downEvent); | 686 sendKeyEvent(downEvent); |
| 673 sendKeyEvent(builder.createVirtualKeyEvent(detail, "keyup")); | 687 sendKeyEvent(builder.createVirtualKeyEvent(detail, "keyup")); |
| 674 return true; | 688 return true; |
| 675 } | 689 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 } | 731 } |
| 718 } | 732 } |
| 719 } | 733 } |
| 720 if (keysetsLoaded) | 734 if (keysetsLoaded) |
| 721 console.error('No default keyset found for ' + this.layout); | 735 console.error('No default keyset found for ' + this.layout); |
| 722 return false; | 736 return false; |
| 723 } | 737 } |
| 724 }); | 738 }); |
| 725 </script> | 739 </script> |
| 726 </polymer-element> | 740 </polymer-element> |
| OLD | NEW |