object = HookKeyStroke(obHandler, ch )

Hook a key stroke handler


obHandler : object

The handler of the keystroke. This must be a callable object.

ch : int

The ID for the keystroke to be handled. This may be an ascii code, or a virtual key code.


The handler object passed will be called as the application receives WM_CHAR message for the specified character code. The handler will be called with 2 arguments
The handler object (as per all hook functions)
The keystroke being handled.
If the handler returns TRUE, then the keystroke will be passed on to the default handler, otherwise the keystroke will be consumed.
Note: This handler will not be called if a PyCWnd::HookAllKeyStrokes hook is in place.

Return Value

The return value is the previous handler, or None.