updateModifierState = function updateModifierState(remoteState,
        localState, keysyms, keyEvent) {

        var i;

        // Do not trust changes in modifier state for events directly involving
        // that modifier: (1) the flag may erroneously be cleared despite
        // another version of the same key still being held and (2) the change
        // in flag may be due to the current event being processed, thus
        // updating things here is at best redundant and at worst incorrect
        if (keysyms.indexOf(keyEvent.keysym) !== -1)
            return;

        // Release all related keys if modifier is implicitly released
        if (remoteState && localState === false) {
            for (i = 0; i < keysyms.length; i++) {
                guac_keyboard.release(keysyms[i]);
            }
        }

        // Press if modifier is implicitly pressed
        else if (!remoteState && localState) {

            // Verify that modifier flag isn't already pressed or already set
            // due to another version of the same key being held down
            for (i = 0; i < keysyms.length; i++) {
                if (guac_keyboard.pressed[keysyms[i]])
                    return;
            }

            // Mark as implicitly pressed only if there is other information
            // within the key event relating to a different key. Some
            // platforms, such as iOS, will send essentially empty key events
            // for modifier keys, using only the modifier flags to signal the
            // identity of the key.
            var keysym = keysyms[0];
            if (keyEvent.keysym)
                implicitlyPressed[keysym] = true;

            guac_keyboard.press(keysym);

        }

    }
Given the remote and local state of a particular key, resynchronizes the
remote state of that key with the local state through pressing or
releasing keysyms.

@private
@param {Boolean} remoteState
    Whether the key is currently pressed remotely.

@param {Boolean} localState
    Whether the key is currently pressed remotely locally. If the state
    of the key is not known, this may be undefined.

@param {Number[]} keysyms
    The keysyms which represent the key being updated.

@param {KeyEvent} keyEvent
    Guacamole's current best interpretation of the key event being
    processed.