function update(modifiers, normModifiers) {
  var keyboardGlyphData = getKeyboardGlyphData();
  var shortcutData = getShortcutData();
  var layout = getLayout();
  for (var i = 0; i < layout.length; ++i) {
    var identifier = remapIdentifier(layout[i][0]);
    var keyData = keyboardGlyphData.keys[identifier];
    var classes = getKeyClasses(identifier, modifiers, normModifiers);
    var keyLabel = getKeyLabel(keyData, normModifiers);
    var shortcutId = shortcutData[getAction(keyLabel, normModifiers)];
    if (modifiers.length == 0 && (identifier == '2A' || identifier == '36')) {
      // Either the right or left shift keys are used to disable the caps lock
      // if it was enabled. To fix crbug.com/453623.
      shortcutId = 'keyboardOverlayDisableCapsLock';
    }

    classes.push('keyboard-overlay-key-background');

    if (shortcutId == 'keyboardOverlayVoiceInteraction' &&
        (!isVoiceInteractionEnabled() || hasKeyboardLayout2())) {
      // The shortcut should be disabled either voice interaction is disabled or
      // keyboard layout 2 is in use (in which case a dedicated key for voice
      // interaction exists).
      continue;
    }

    // Currently hidden behind experimental accessibility features flag.
    if (shortcutId == 'keyboardOverlayToggleDictation')
      continue;

    if ((shortcutId == 'keyboardOverlayMoveWindowToBelowDisplay' ||
         shortcutId == 'keyboardOverlayMoveWindowToLeftDisplay' ||
         shortcutId == 'keyboardOverlayMoveWindowToRightDisplay' ||
         shortcutId == 'keyboardOverlayMoveWindowToAboveDisplay') &&
        !isDisplayMoveWindowAccelsEnabled()) {
      continue;
    }

    if (shortcutId) {
      classes.push('is-shortcut');
      classes.push('keyboard-overlay-shortcut-key-background');
    }

    var key = $(keyId(identifier, i));
    key.className = classes.join(' ');

    if (!keyData) {
      continue;
    }

    var keyText = $(keyTextId(identifier, i));
    var keyTextValue = getKeyTextValue(keyData);
    if (keyTextValue) {
      keyText.style.visibility = 'visible';
    } else {
      keyText.style.visibility = 'hidden';
    }
    keyText.textContent = keyTextValue;

    var shortcutText = $(shortcutTextId(identifier, i));
    if (shortcutId) {
      shortcutText.style.visibility = 'visible';
      shortcutText.textContent = loadTimeData.getString(shortcutId);
    } else {
      shortcutText.style.visibility = 'hidden';
    }

    if (layout[i][1] == 'COMPOUND_ENTER_KEY') {
      var overlayDivClasses =
          getKeyClasses(identifier, modifiers, normModifiers);
      if (shortcutId)
        overlayDivClasses.push('is-shortcut');
      $(keyId(identifier, i) + '-sub').className = overlayDivClasses.join(' ');
    }

    var format = keyboardGlyphData.keys[layout[i][0]].format;
    if (format) {
      if (format == 'left' || format == 'right') {
        shortcutText.style.textAlign = format;
        keyText.style.textAlign = format;
      }
    }
  }
}
/**
 * Updates the whole keyboard.
 * @param {Array} modifiers Key Modifier list.
 * @param {Array} normModifiers Key Modifier list ignoring the distinction
 *                between right and left keys.
 */
Updates the whole keyboard.
@param {Array} modifiers Key Modifier list.
@param {Array} normModifiers Key Modifier list ignoring the distinction
between right and left keys.
Updates the whole keyboard . @param { Array } modifiers Key Modifier list . @param { Array } normModifiers Key Modifier list ignoring the distinction between right and left keys .
function update(modifiers, normModifiers) {
  var keyboardGlyphData = getKeyboardGlyphData();
  var shortcutData = getShortcutData();
  var layout = getLayout();
  for (var i = 0; i < layout.length; ++i) {
    var identifier = remapIdentifier(layout[i][0]);
    var keyData = keyboardGlyphData.keys[identifier];
    var classes = getKeyClasses(identifier, modifiers, normModifiers);
    var keyLabel = getKeyLabel(keyData, normModifiers);
    var shortcutId = shortcutData[getAction(keyLabel, normModifiers)];
    if (modifiers.length == 0 && (identifier == '2A' || identifier == '36')) {
      shortcutId = 'keyboardOverlayDisableCapsLock';
    }
    classes.push('keyboard-overlay-key-background');
    if (shortcutId == 'keyboardOverlayVoiceInteraction' &&
        (!isVoiceInteractionEnabled() || hasKeyboardLayout2())) {
      continue;
    }
    if (shortcutId == 'keyboardOverlayToggleDictation')
      continue;
    if ((shortcutId == 'keyboardOverlayMoveWindowToBelowDisplay' ||
         shortcutId == 'keyboardOverlayMoveWindowToLeftDisplay' ||
         shortcutId == 'keyboardOverlayMoveWindowToRightDisplay' ||
         shortcutId == 'keyboardOverlayMoveWindowToAboveDisplay') &&
        !isDisplayMoveWindowAccelsEnabled()) {
      continue;
    }
    if (shortcutId) {
      classes.push('is-shortcut');
      classes.push('keyboard-overlay-shortcut-key-background');
    }
    var key = $(keyId(identifier, i));
    key.className = classes.join(' ');
    if (!keyData) {
      continue;
    }
    var keyText = $(keyTextId(identifier, i));
    var keyTextValue = getKeyTextValue(keyData);
    if (keyTextValue) {
      keyText.style.visibility = 'visible';
    } else {
      keyText.style.visibility = 'hidden';
    }
    keyText.textContent = keyTextValue;
    var shortcutText = $(shortcutTextId(identifier, i));
    if (shortcutId) {
      shortcutText.style.visibility = 'visible';
      shortcutText.textContent = loadTimeData.getString(shortcutId);
    } else {
      shortcutText.style.visibility = 'hidden';
    }
    if (layout[i][1] == 'COMPOUND_ENTER_KEY') {
      var overlayDivClasses =
          getKeyClasses(identifier, modifiers, normModifiers);
      if (shortcutId)
        overlayDivClasses.push('is-shortcut');
      $(keyId(identifier, i) + '-sub').className = overlayDivClasses.join(' ');
    }
    var format = keyboardGlyphData.keys[layout[i][0]].format;
    if (format) {
      if (format == 'left' || format == 'right') {
        shortcutText.style.textAlign = format;
        keyText.style.textAlign = format;
      }
    }
  }
}
function update ( modifiers , normModifiers ) { var keyboardGlyphData = getKeyboardGlyphData ( ) ; var shortcutData = getShortcutData ( ) ; var layout = getLayout ( ) ; for ( var i = 0 ; i < layout . length ; ++ i ) { var identifier = remapIdentifier ( layout [ i ] [ 0 ] ) ; var keyData = keyboardGlyphData . keys [ identifier ] ; var classes = getKeyClasses ( identifier , modifiers , normModifiers ) ; var keyLabel = getKeyLabel ( keyData , normModifiers ) ; var shortcutId = shortcutData [ getAction ( keyLabel , normModifiers ) ] ; if ( modifiers . length == 0 && ( identifier == '2A' || identifier == '36' ) ) { shortcutId = 'keyboardOverlayDisableCapsLock' ; } classes . push ( 'keyboard-overlay-key-background' ) ; if ( shortcutId == 'keyboardOverlayVoiceInteraction' && ( ! isVoiceInteractionEnabled ( ) || hasKeyboardLayout2 ( ) ) ) { continue ; } if ( shortcutId == 'keyboardOverlayToggleDictation' ) continue ; if ( ( shortcutId == 'keyboardOverlayMoveWindowToBelowDisplay' || shortcutId == 'keyboardOverlayMoveWindowToLeftDisplay' || shortcutId == 'keyboardOverlayMoveWindowToRightDisplay' || shortcutId == 'keyboardOverlayMoveWindowToAboveDisplay' ) && ! isDisplayMoveWindowAccelsEnabled ( ) ) { continue ; } if ( shortcutId ) { classes . push ( 'is-shortcut' ) ; classes . push ( 'keyboard-overlay-shortcut-key-background' ) ; } var key = $ ( keyId ( identifier , i ) ) ; key . className = classes . join ( ' ' ) ; if ( ! keyData ) { continue ; } var keyText = $ ( keyTextId ( identifier , i ) ) ; var keyTextValue = getKeyTextValue ( keyData ) ; if ( keyTextValue ) { keyText . style . visibility = 'visible' ; } else { keyText . style . visibility = 'hidden' ; } keyText . textContent = keyTextValue ; var shortcutText = $ ( shortcutTextId ( identifier , i ) ) ; if ( shortcutId ) { shortcutText . style . visibility = 'visible' ; shortcutText . textContent = loadTimeData . getString ( shortcutId ) ; } else { shortcutText . style . visibility = 'hidden' ; } if ( layout [ i ] [ 1 ] == 'COMPOUND_ENTER_KEY' ) { var overlayDivClasses = getKeyClasses ( identifier , modifiers , normModifiers ) ; if ( shortcutId ) overlayDivClasses . push ( 'is-shortcut' ) ; $ ( keyId ( identifier , i ) + '-sub' ) . className = overlayDivClasses . join ( ' ' ) ; } var format = keyboardGlyphData . keys [ layout [ i ] [ 0 ] ] . format ; if ( format ) { if ( format == 'left' || format == 'right' ) { shortcutText . style . textAlign = format ; keyText . style . textAlign = format ; } } } }
Updates the whole keyboard.
Updates the whole keyboard .
// Either the right or left shift keys are used to disable the caps lock // if it was enabled. To fix crbug.com/453623. // The shortcut should be disabled either voice interaction is disabled or // keyboard layout 2 is in use (in which case a dedicated key for voice // interaction exists). // Currently hidden behind experimental accessibility features flag.