function indexof_keyup(keydown) {

        var i;

        // Search event log for keyup events having the given keysym
        for (i=0; i<eventLog.length; i++) {

            // Return index of key event if found
            var event = eventLog[i];
            if (event instanceof KeyupEvent && event.keyCode === keydown.keyCode)
                return i;

        }

        // No such keyup found
        return -1;

    }
Searches the event log for a keyup event corresponding to the given
keydown event, returning its index within the log.

@param {KeydownEvent} keydown The keydown event whose corresponding keyup
                              event we are to search for.
@returns {Number} The index of the first keyup event in the event log
                  matching the given keydown event, or -1 if no such
                  event exists.