AddKeyboardShortcut()

Syntax

AddKeyboardShortcut(#Window, Shortcut, Event)
Description
Add or replace a keyboard shortcut to the specified window. A shortcut generates a menu event (like a menu item) as most of them are used in conjunction with menus.

Parameters

#Window The window to use.
Shortcut It can be one of the following constants:
  #PB_Shortcut_Back
  #PB_Shortcut_Tab
  #PB_Shortcut_Clear
  #PB_Shortcut_Return
  #PB_Shortcut_Capital
  #PB_Shortcut_Escape
  #PB_Shortcut_Space
  #PB_Shortcut_PageUp
  #PB_Shortcut_PageDown
  #PB_Shortcut_End
  #PB_Shortcut_Home
  #PB_Shortcut_Left
  #PB_Shortcut_Up
  #PB_Shortcut_Right
  #PB_Shortcut_Down
  #PB_Shortcut_Insert
  #PB_Shortcut_Delete
  #PB_Shortcut_0
  #PB_Shortcut_1
  #PB_Shortcut_2
  #PB_Shortcut_3
  #PB_Shortcut_4
  #PB_Shortcut_5
  #PB_Shortcut_6
  #PB_Shortcut_7
  #PB_Shortcut_8
  #PB_Shortcut_9
  #PB_Shortcut_A
  #PB_Shortcut_B
  #PB_Shortcut_C
  #PB_Shortcut_D
  #PB_Shortcut_E
  #PB_Shortcut_F
  #PB_Shortcut_G
  #PB_Shortcut_H
  #PB_Shortcut_I
  #PB_Shortcut_J
  #PB_Shortcut_K
  #PB_Shortcut_L
  #PB_Shortcut_M
  #PB_Shortcut_N
  #PB_Shortcut_O
  #PB_Shortcut_P
  #PB_Shortcut_Q
  #PB_Shortcut_R
  #PB_Shortcut_S
  #PB_Shortcut_T
  #PB_Shortcut_U
  #PB_Shortcut_V
  #PB_Shortcut_W
  #PB_Shortcut_X
  #PB_Shortcut_Y
  #PB_Shortcut_Z
  #PB_Shortcut_Pad0
  #PB_Shortcut_Pad1
  #PB_Shortcut_Pad2
  #PB_Shortcut_Pad3
  #PB_Shortcut_Pad4
  #PB_Shortcut_Pad5
  #PB_Shortcut_Pad6
  #PB_Shortcut_Pad7
  #PB_Shortcut_Pad8
  #PB_Shortcut_Pad9
  #PB_Shortcut_Multiply
  #PB_Shortcut_Add
  #PB_Shortcut_Separator
  #PB_Shortcut_Subtract
  #PB_Shortcut_Decimal
  #PB_Shortcut_Divide
  #PB_Shortcut_F1
  #PB_Shortcut_F2
  #PB_Shortcut_F3
  #PB_Shortcut_F4
  #PB_Shortcut_F5
  #PB_Shortcut_F6
  #PB_Shortcut_F7
  #PB_Shortcut_F8
  #PB_Shortcut_F9
  #PB_Shortcut_F10
  #PB_Shortcut_F11
  #PB_Shortcut_F12
The above key can be combined with any of the following constants:
  #PB_Shortcut_Shift
  #PB_Shortcut_Control
  #PB_Shortcut_Alt
  #PB_Shortcut_Command
Event The number which will be returned by the EventMenu() function. By default, a window already has the #PB_Shortcut_Tab and #PB_Shortcut_Tab|#PB_Shortcut_Shift shortcuts to handle tab and shift-tab correctly through the gadgets. A shortcut can be removed with RemoveKeyboardShortcut().

Return value

None.

Remarks

The #PB_Shortcut_Command constant is only useful on Mac OSX and allow to use the 'Apple' key (left or right) to define shortcuts. This constant is also supported on others OS (to ease portability), but will act like #PB_Shortcut_Control.

Example

  Procedure MenuEvents()
    Debug "Menu event: " + EventMenu()
  EndProcedure
  
  If OpenWindow(0, 0, 0, 295, 260, "CTRL+F Shortcut", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
    
    AddKeyboardShortcut(0, #PB_Shortcut_Control | #PB_Shortcut_F, 15)
    
    BindEvent(#PB_Event_Menu, @MenuEvents())
  EndIf

See Also

RemoveKeyboardShortcut()

Supported OS

All

Window Index - AddWindowTimer() ->