B2G/gaia/apps/keyboard/js/keyboard.js
// The user is releasing a key so the key has been pressed. The meat is here.
The user is releasing a key so the key has been pressed. The meat is here.
The user is releasing a key so the key has been pressed . The meat is here .
function endPress(target, coords, touchId) {
  clearTimeout(deleteTimeout);
  clearInterval(deleteInterval);
  clearTimeout(menuTimeout);
  var wasShowingKeyboardLayoutMenu = isShowingKeyboardLayoutMenu;
  hideAlternatives();
  hideKeyboardLayoutMenu();
  if (!target || !isNormalKey(target))
    return;
  var dataset = target.dataset;
  if (dataset.selection) {
    if (inputMethod.select) {
      inputMethod.select(dataset.data);
    }
    IMERender.highlightKey(target);
    return;
  }
  IMERender.unHighlightKey(target);
  if (target.dataset.ignoreEndPress) {
    delete target.dataset.ignoreEndPress;
    return;
  }
  var keyCode = parseInt(target.dataset.keycode);
  if (keyCode == KeyEvent.DOM_VK_BACK_SPACE)
    return;
  if (keyCode != KeyEvent.DOM_VK_SPACE)
    isContinousSpacePressed = false;
  switch (keyCode) {
  case BASIC_LAYOUT:
    setLayoutPage(LAYOUT_PAGE_DEFAULT);
    break;
  case ALTERNATE_LAYOUT:
    setLayoutPage(LAYOUT_PAGE_SYMBOLS_I);
    break;
  case KeyEvent.DOM_VK_ALT:
    if (layoutPage === LAYOUT_PAGE_SYMBOLS_I) {
      setLayoutPage(LAYOUT_PAGE_SYMBOLS_II);
    } else {
      setLayoutPage(LAYOUT_PAGE_SYMBOLS_I);
    }
    break;
  case SWITCH_KEYBOARD:
    if (target.dataset.keyboard || !wasShowingKeyboardLayoutMenu)
      switchKeyboard(target);
    break;
  case TOGGLE_CANDIDATE_PANEL:
    if (IMERender.ime.classList.contains('candidate-panel')) {
      IMERender.ime.classList.remove('candidate-panel');
      IMERender.ime.classList.add('full-candidate-panel');
    } else {
      IMERender.ime.classList.add('candidate-panel');
      IMERender.ime.classList.remove('full-candidate-panel');
    }
    break;
  case KeyEvent.DOM_VK_CAPS_LOCK:
    if (isWaitingForSecondTap) {
      isWaitingForSecondTap = false;
      setUpperCase(true, true);
    } else {
      isWaitingForSecondTap = true;
      window.setTimeout(
        function() {
          isWaitingForSecondTap = false;
        },
        CAPS_LOCK_TIMEOUT
      );
      setUpperCase(!isUpperCase, false);
    }
    break;
  default:
    if (target.dataset.compositekey) {
      var compositeKey = target.dataset.compositekey;
      for (var i = 0; i < compositeKey.length; i++) {
        inputMethod.click(compositeKey.charCodeAt(i));
      }
    }
    else {
      inputMethod.click(keyCode);
    }
    break;
  }
}
function endPress ( target , coords , touchId ) { clearTimeout ( deleteTimeout ) ; clearInterval ( deleteInterval ) ; clearTimeout ( menuTimeout ) ; var wasShowingKeyboardLayoutMenu = isShowingKeyboardLayoutMenu ; hideAlternatives ( ) ; hideKeyboardLayoutMenu ( ) ; if ( ! target || ! isNormalKey ( target ) ) return ; var dataset = target . dataset ; if ( dataset . selection ) { if ( inputMethod . select ) { inputMethod . select ( dataset . data ) ; } IMERender . highlightKey ( target ) ; return ; } IMERender . unHighlightKey ( target ) ; if ( target . dataset . ignoreEndPress ) { delete target . dataset . ignoreEndPress ; return ; } var keyCode = parseInt ( target . dataset . keycode ) ; if ( keyCode == KeyEvent . DOM_VK_BACK_SPACE ) return ; if ( keyCode != KeyEvent . DOM_VK_SPACE ) isContinousSpacePressed = false ; switch ( keyCode ) { case BASIC_LAYOUT : setLayoutPage ( LAYOUT_PAGE_DEFAULT ) ; break ; case ALTERNATE_LAYOUT : setLayoutPage ( LAYOUT_PAGE_SYMBOLS_I ) ; break ; case KeyEvent . DOM_VK_ALT : if ( layoutPage === LAYOUT_PAGE_SYMBOLS_I ) { setLayoutPage ( LAYOUT_PAGE_SYMBOLS_II ) ; } else { setLayoutPage ( LAYOUT_PAGE_SYMBOLS_I ) ; } break ; case SWITCH_KEYBOARD : if ( target . dataset . keyboard || ! wasShowingKeyboardLayoutMenu ) switchKeyboard ( target ) ; break ; case TOGGLE_CANDIDATE_PANEL : if ( IMERender . ime . classList . contains ( 'candidate-panel' ) ) { IMERender . ime . classList . remove ( 'candidate-panel' ) ; IMERender . ime . classList . add ( 'full-candidate-panel' ) ; } else { IMERender . ime . classList . add ( 'candidate-panel' ) ; IMERender . ime . classList . remove ( 'full-candidate-panel' ) ; } break ; case KeyEvent . DOM_VK_CAPS_LOCK : if ( isWaitingForSecondTap ) { isWaitingForSecondTap = false ; setUpperCase ( true , true ) ; } else { isWaitingForSecondTap = true ; window . setTimeout ( function ( ) { isWaitingForSecondTap = false ; } , CAPS_LOCK_TIMEOUT ) ; setUpperCase ( ! isUpperCase , false ) ; } break ; default : if ( target . dataset . compositekey ) { var compositeKey = target . dataset . compositekey ; for ( var i = 0 ; i < compositeKey . length ; i ++ ) { inputMethod . click ( compositeKey . charCodeAt ( i ) ) ; } } else { inputMethod . click ( keyCode ) ; } break ; } }
The user is releasing a key so the key has been pressed.
The user is releasing a key so the key has been pressed .
// IME candidate selected // We use dataset.data instead of target.textContent because the // text actually displayed to the user might have an ellipsis in it // to make it fit. // The alternate keys of telLayout and numberLayout do not // trigger keypress on key release. // Delete is a special key, it reacts when pressed not released // Reset the flag when a non-space key is pressed, // used in space key double tap handling // Handle normal key // Return to default page // Switch to numbers+symbols page // alternate between pages 1 and 2 of SYMBOLS // Switch language (keyboard) // If the user selected a new keyboard layout or quickly tapped the // switch layouts button then switch to a new keyboard layout // Expand / shrink the candidate panel // Shift or caps lock // Already waiting for caps lock // Normal behavior: set timeout for second tap and toggle caps // Toggle caps // Normal key // Keys with this attribute set send more than a single character // Like ".com" or "2nd" or (in Catalan) "l·l".