InfoConnect VBA Guide
Attachmate.Reflection.Objects.Emulation.IbmHosts Library / KeyboardMapper Object / Contains Method
The Keys enumeration value that specifies the key sequence to query for.
Example
In This Topic
    Contains Method (KeyboardMapper)
    In This Topic
    Returns whether the current keyboard map has a mapping for a specified key combination. This method only works for non-extended keys.
    Syntax
    expression.Contains( _
       ByVal key As Keys _
    ) As Boolean
    where expression is a variable that represents a KeyboardMapper Object

    Parameters

    key
    The Keys enumeration value that specifies the key sequence to query for.

    Return Value

    True if the current keyboard map contains a mapping for key, false if not.
    Example
    This example adds a key combination that runs a macro to a keyboard map. It uses the Contains method to determine whether the combination is already in use.
    Public Sub MapKeyToMacro()
        Dim kbmapping As KeyboardMapping
        Dim sequence As InputMapActionSequence
        Dim action As InputMapAction
        Dim path As String
        Dim isKeyInMap As Boolean
        
        Dim key, altKey As Keys
        
        'Define two key combinations in case the first key combination is mapped
        key = Keys_Control + Keys_B
        altKey = Keys_Control + Keys_D
        
        'Se the file path and name for the new keyboard map
        path = Environ$("USERPROFILE") & "\Documents\Micro Focus\InfoConnect\Keyboard Maps\" & "myKeyboardMap.xkb"
     
        Set kbmapping = New KeyboardMapping
        Set sequence = New InputMapActionSequence
                             
        'Set up the action to run a recorded macro named Test in a module named Module1
        Set action = New InputMapAction
        action.ActionId = InputMapActionID_RunMacroAction
        action.AddParameter "Module1.Test" 'This is the name of the module the macro is in and the macro name
        action.AddParameterAsInteger MacroEnumerationOption.MacroEnumerationOption_Document 'Look for the macro in this Session project
        action.AddParameterAsBoolean False 'Don't ask for any input at runtime
        sequence.Add action 'Add the action to the action sequence
        
        'If the key combination is in the map, use the alternate
        isKeyInMap = ThisIbmTerminal.KeyboardMapper.contains(key)
        If isKeyInMap = True Then
            Debug.Print "in map"
            key = altKey
        End If
        
        'Assign the key combination to the new action
        kbmapping.key = key
     
        'Map the key assigned  to the keyboard mapping to the sequence
        Set kbmapping.mapping = sequence
     
        'Add the new mapping to the session keyboard map
        ThisIbmTerminal.KeyboardMapper.AddMapping kbmapping
        
        'Save the new file
        ThisIbmTerminal.KeyboardMapper.SaveAs (path)
                              
    End Sub
    See Also