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" attributes="keyset layout rows capsLocked"> | 10 on-enable-dbl="enableDbl" attributes="keyset layout rows capsLocked"> |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 */ | 282 */ |
283 keyDown: function(event, detail) { | 283 keyDown: function(event, detail) { |
284 if (this.skipEvent(detail)) | 284 if (this.skipEvent(detail)) |
285 return; | 285 return; |
286 | 286 |
287 if (this.lastPressedKey) | 287 if (this.lastPressedKey) |
288 this.lastPressedKey.classList.remove('active'); | 288 this.lastPressedKey.classList.remove('active'); |
289 this.lastPressedKey = event.target; | 289 this.lastPressedKey = event.target; |
290 this.lastPressedKey.classList.add('active'); | 290 this.lastPressedKey.classList.add('active'); |
291 repeatKey.cancel(); | 291 repeatKey.cancel(); |
292 | |
293 var char = detail.char; | |
294 switch(char) { | |
295 case 'Shift': | |
296 // Removes caps-lock if caps-locked. | |
297 if(this.classList.contains('caps-locked')) { | |
298 this.classList.remove('caps-locked'); | |
299 } | |
300 break; | |
301 default: | |
302 break; | |
303 } | |
304 | |
305 // A transition key was pressed, immediately move to new keyset. | |
292 var toKeyset = detail.toKeyset; | 306 var toKeyset = detail.toKeyset; |
293 if (toKeyset) { | 307 if (toKeyset) { |
294 this.keyset = toKeyset; | 308 this.keyset = toKeyset; |
295 this.querySelector('#' + this.layout + '-' + this.keyset).nextKeyset = | 309 this.querySelector('#' + this.layout + '-' + this.keyset).nextKeyset = |
296 detail.nextKeyset; | 310 detail.nextKeyset; |
297 return; | 311 return; |
298 } | 312 } |
299 | 313 |
300 if (detail.repeat) { | 314 if (detail.repeat) { |
301 this.keyTyped(detail); | 315 this.keyTyped(detail); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
392 return; | 406 return; |
393 if (swipeInProgress) | 407 if (swipeInProgress) |
394 return; | 408 return; |
395 this.lastPressedKey.classList.remove('active'); | 409 this.lastPressedKey.classList.remove('active'); |
396 if (this.lastPressedKey != event.target) | 410 if (this.lastPressedKey != event.target) |
397 return; | 411 return; |
398 if (repeatKey.key == event.target) { | 412 if (repeatKey.key == event.target) { |
399 repeatKey.cancel(); | 413 repeatKey.cancel(); |
400 return; | 414 return; |
401 } | 415 } |
402 var toKeysetId = detail.toKeyset; | 416 var toKeysetId = detail.toKeyset; |
bshe
2013/09/16 17:52:01
It is probably worth mention in a comment here abo
rsadam
2013/09/16 18:23:49
Done.
| |
403 // Keyset transition key. | 417 // Keyset transition key. |
404 if (toKeysetId) { | 418 if (toKeysetId) { |
405 this.keyset = toKeysetId; | 419 this.keyset = toKeysetId; |
406 this.querySelector('#' + this.layout + '-' + this.keyset).nextKeyset = | 420 this.querySelector('#' + this.layout + '-' + this.keyset).nextKeyset = |
407 detail.nextKeyset; | 421 detail.nextKeyset; |
408 } | 422 } |
409 var toLayoutId = detail.toLayout; | 423 var toLayoutId = detail.toLayout; |
410 // Layout transition key. | 424 // Layout transition key. |
411 if (toLayoutId) | 425 if (toLayoutId) |
412 this.layout = toLayoutId; | 426 this.layout = toLayoutId; |
413 var char = detail.char; | 427 var char = detail.char; |
414 if (enterUpperOnSpace) { | 428 if (enterUpperOnSpace) { |
415 enterUpperOnSpace = false; | 429 enterUpperOnSpace = false; |
416 if (char == ' ') | 430 if (char == ' ') |
417 this.keyset = 'upper'; | 431 this.keyset = 'upper'; |
418 } | 432 } |
419 switch(char) { | 433 switch(char) { |
420 case 'Invalid': | 434 case 'Invalid': |
421 swipeStatus.swipeFlags = 0; | 435 swipeStatus.swipeFlags = 0; |
422 return; | 436 return; |
423 case 'Shift': | 437 case 'Shift': |
424 swipeStatus.swipeFlags = 0; | 438 swipeStatus.swipeFlags = 0; |
425 // We have reverted to lower case. | |
426 if(this.classList.contains('caps-locked')) | |
427 this.classList.remove('caps-locked'); | |
428 return; | 439 return; |
429 case 'Microphone': | 440 case 'Microphone': |
430 this.voiceInput_.onDown(); | 441 this.voiceInput_.onDown(); |
431 return; | 442 return; |
432 case '.': | 443 case '.': |
433 case '?': | 444 case '?': |
434 case '!': | 445 case '!': |
435 enterUpperOnSpace = true; | 446 enterUpperOnSpace = true; |
436 break; | 447 break; |
437 default: | 448 default: |
(...skipping 12 matching lines...) Expand all Loading... | |
450 * @param {Object} detail The detail of pressed key. | 461 * @param {Object} detail The detail of pressed key. |
451 */ | 462 */ |
452 keyLongpress: function(event, detail) { | 463 keyLongpress: function(event, detail) { |
453 // If the gesture is long press, remove the pointermove listener. | 464 // If the gesture is long press, remove the pointermove listener. |
454 this.removeEventListener('pointermove', this.swipeHandler, false); | 465 this.removeEventListener('pointermove', this.swipeHandler, false); |
455 var toKeyset = detail.toKeyset; | 466 var toKeyset = detail.toKeyset; |
456 // Keyset transtion key. | 467 // Keyset transtion key. |
457 if (toKeyset) { | 468 if (toKeyset) { |
458 this.keyset = toKeyset; | 469 this.keyset = toKeyset; |
459 this.querySelector('#' + this.layout + '-' + this.keyset).nextKeyset = | 470 this.querySelector('#' + this.layout + '-' + this.keyset).nextKeyset = |
460 detail.nextKeyset; | 471 detail.nextKeyset; |
bshe
2013/09/16 17:52:01
nit: accidentally removed the empty line?
rsadam
2013/09/16 18:23:49
Done.
| |
461 | |
462 // Locks the keyset before removing active to prevent flicker. | 472 // Locks the keyset before removing active to prevent flicker. |
463 this.classList.add('caps-locked'); | 473 this.classList.add('caps-locked'); |
464 // Makes last pressed key inactive if transit to a new keyset on long | 474 // Makes last pressed key inactive if transit to a new keyset on long |
465 // press. | 475 // press. |
466 this.lastPressedKey.classList.remove('active'); | 476 this.lastPressedKey.classList.remove('active'); |
467 } | 477 } |
468 }, | 478 }, |
469 | 479 |
470 /** | 480 /** |
471 * Handles a change in the keyboard layout. Auto-selects the default | 481 * Handles a change in the keyboard layout. Auto-selects the default |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 } | 557 } |
548 } | 558 } |
549 if (keysetsLoaded) | 559 if (keysetsLoaded) |
550 console.error('No default keyset found for ' + this.layout); | 560 console.error('No default keyset found for ' + this.layout); |
551 return false; | 561 return false; |
552 } | 562 } |
553 }); | 563 }); |
554 </script> | 564 </script> |
555 </polymer-element> | 565 </polymer-element> |
556 | 566 |
OLD | NEW |