function apply_key_behavior(key) {

        function __update_key(e) {

            var guac = GuacUI.Client.attachedClient;
            if (!guac)
                return;

            e.preventDefault();
            e.stopPropagation();

            // Pull properties of key
            var keysym  = parseInt(key.getAttribute("data-keysym"));
            var sticky  = (key.getAttribute("data-sticky") === "true");
            var pressed = (key.className.indexOf("pressed") !== -1); 

            // If sticky, toggle pressed state
            if (sticky) {
                if (pressed) {
                    GuacUI.removeClass(key, "pressed");
                    guac.sendKeyEvent(0, keysym);
                    delete active_sticky_keys[keysym];
                }
                else {
                    GuacUI.addClass(key, "pressed");
                    guac.sendKeyEvent(1, keysym);
                    active_sticky_keys[keysym] = key;
                }
            }

            // For all non-sticky keys, press and release key immediately
            else
                send_keysym(keysym);

        }

        var ignore_mouse = false;

        // Press/release key when clicked
        key.addEventListener("mousedown", function __mouse_key(e) {

            // Ignore clicks which follow touches
            if (ignore_mouse)
                return;

            __update_key(e);

        }, false);

        // Press/release key when tapped 
        key.addEventListener("touchstart", function __touch_key(e) {

            // Ignore following clicks
            ignore_mouse = true;

            __update_key(e);

        }, false);

        // Restore handling of mouse events when mouse is used
        key.addEventListener("mousemove", function __reset_mouse() {
            ignore_mouse = false;
        }, false);

    }
Presses/releases the keysym defined by the "data-keysym" attribute on
the given element whenever the element is pressed. The "data-sticky"
attribute, if present and set to "true", causes the key to remain
pressed until text is sent.

@param {Element} key The element which will control its associated key.