src/OnScreenKeyboard.js
function press(keyName, keyElement) {

        // Press key if not yet pressed
        if (!pressed[keyName]) {

            addClass(keyElement, "guac-keyboard-pressed");

            // Get current key based on modifier state
            var key = getActiveKey(keyName);

            // Update modifier state
            if (key.modifier) {

                // Construct classname for modifier
                var modifierClass = "guac-keyboard-modifier-" + getCSSName(key.modifier);

                // Retrieve originally-pressed keysym, if modifier was already pressed
                var originalKeysym = modifierKeysyms[key.modifier];

                // Activate modifier if not pressed
                if (!originalKeysym) {
                    
                    addClass(keyboard, modifierClass);
                    modifierKeysyms[key.modifier] = key.keysym;
                    
                    // Send key event
                    if (osk.onkeydown)
                        osk.onkeydown(key.keysym);

                }

                // Deactivate if not pressed
                else {

                    removeClass(keyboard, modifierClass);
                    delete modifierKeysyms[key.modifier];
                    
                    // Send key event
                    if (osk.onkeyup)
                        osk.onkeyup(originalKeysym);

                }

            }

            // If not modifier, send key event now
            else if (osk.onkeydown)
                osk.onkeydown(key.keysym);

            // Mark key as pressed
            pressed[keyName] = true;

        }

    }
function press(keyName, keyElement) {

        // Press key if not yet pressed
        if (!pressed[keyName]) {

            addClass(keyElement, "guac-keyboard-pressed");

            // Get current key based on modifier state
            var key = getActiveKey(keyName);

            // Update modifier state
            if (key.modifier) {

                // Construct classname for modifier
                var modifierClass = "guac-keyboard-modifier-" + getCSSName(key.modifier);

                // Retrieve originally-pressed keysym, if modifier was already pressed
                var originalKeysym = modifierKeysyms[key.modifier];

                // Activate modifier if not pressed
                if (!originalKeysym) {
                    
                    addClass(keyboard, modifierClass);
                    modifierKeysyms[key.modifier] = key.keysym;
                    
                    // Send key event
                    if (osk.onkeydown)
                        osk.onkeydown(key.keysym);

                }

                // Deactivate if not pressed
                else {

                    removeClass(keyboard, modifierClass);
                    delete modifierKeysyms[key.modifier];
                    
                    // Send key event
                    if (osk.onkeyup)
                        osk.onkeyup(originalKeysym);

                }

            }

            // If not modifier, send key event now
            else if (osk.onkeydown)
                osk.onkeydown(key.keysym);

            // Mark key as pressed
            pressed[keyName] = true;

        }

    }
function press ( keyName , keyElement ) { // Press key if not yet pressed if ( ! pressed [ keyName ] ) { addClass ( keyElement , "guac-keyboard-pressed" ) ; // Get current key based on modifier state var key = getActiveKey ( keyName ) ; // Update modifier state if ( key . modifier ) { // Construct classname for modifier var modifierClass = "guac-keyboard-modifier-" + getCSSName ( key . modifier ) ; // Retrieve originally-pressed keysym, if modifier was already pressed var originalKeysym = modifierKeysyms [ key . modifier ] ; // Activate modifier if not pressed if ( ! originalKeysym ) { addClass ( keyboard , modifierClass ) ; modifierKeysyms [ key . modifier ] = key . keysym ; // Send key event if ( osk . onkeydown ) osk . onkeydown ( key . keysym ) ; } // Deactivate if not pressed else { removeClass ( keyboard , modifierClass ) ; delete modifierKeysyms [ key . modifier ] ; // Send key event if ( osk . onkeyup ) osk . onkeyup ( originalKeysym ) ; } } // If not modifier, send key event now else if ( osk . onkeydown ) osk . onkeydown ( key . keysym ) ; // Mark key as pressed pressed [ keyName ] = true ; } }
Presses the key having the given name, updating the associated key
element with the "guac-keyboard-pressed" CSS class. If the key is
already pressed, this function has no effect.

@private
@param {String} keyName
The name of the key to press.

@param {String} keyElement
The element associated with the given key.
Presses the key having the given name updating the associated key element with the guac - keyboard - pressed CSS class . If the key is already pressed this function has no effect .