Velocity API: WLEvent.onKey()

Version 1

    Return To Index

    WLEvent.onKey()

    Overview

    Set an event handler for the specified key code in the current or specified scope.

    Format

     

    WLEvent.onKey(keyCode,funcRef,scope);
    ParameterDescriptionTypeRequiredNotes
    keyCodeThe key code that invokes this function when pressed.IntegerRequiredUp to four-digit values for standard hex codes required. For example:
    01
    02
    03
    funcRefThe function triggered when the key event is triggered.FunctionRequired
    scopeThe type of scope this key event handler is associated with. Valid values:
    global - Applies the event to all scopes.
    session - Applies the event to a single session.
    screen - Applies the event to a single screen.
    field - Applies the event to a single field.
    StringOptionalIf no value is provided, the current scope is used. Returns false if the scope doesn't exist, true if the handler was successfully registered.

     

    Example

    // This is a hard-coded example of the WLEvent.onKey script.  
    // Triggers the onError function for a session when the specified key is pressed.  
    WLEvent.onKey(13,myHandler,"session");