Skip to content

CommandBarKeyDown Event

Description

Occurs when a key is pressed and a popup menu is open, a popup menu has focus, or a menu item in a popup menu has focus.

Syntax

Public Event CommandBarKeyDown( _
   ByVal CommandBar As [CommandBar](XtremeCommandBars~CommandBar.md), _
   ByRef KeyCode As Long, _
   ByVal Shift As Integer _
)

Parameters

  • CommandBar: CommandBar that had focus when a key was pressed.
  • KeyCode: ASCII code for the key that was pressed.
  • Shift: Specifies whether the Shift, Ctrl, or ALT keys were pressed.

Any combination of the Shift, Alt, and Ctrl keys can be used. The table below shows the possible values for the Shift parameter:

Shift Parameter Value Bit Mask
Shift 1 001
Ctrl 2 010
Shift + Ctrl 3 011
Alt 4 100
Alt + Shift 5 101
Alt + Ctrl 6 110
Shift + Alt + Ctrl 7 111

Remarks

The CommandBarKeyDown event will only occur when a popup menu has focus, or an item in the popup menu has focus. The CommandBar parameter holds all of the menu items of the focused menu.

The CommandBar.SelectedControl property stores the menu item that had focus when a key was pressed.

Example

CommandBarKeyDown Sample (Visual Basic)

This sample illustrates how to use the CommandBarKeyDown event to filter key presses when a menu item has focus.

Private Sub CommandBars_CommandBarKeyDown(CommandBar As XtremeCommandBars.ICommandBar, KeyCode As Long, Shift As Integer)

    ' If the SpaceBar was pressed while a menu item has focus, then execute the item  
    If KeyCode = 32 Then  
        CommandBar.SelectedControl.Execute  
    End If  

End Sub

See Also

CommandBars Control


Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.