def OnKey(self, event):
        """Handles non-standard shortcut events"""

        def switch_to_next_table():
            newtable = self.grid.current_table + 1
            post_command_event(self.grid, self.GridActionTableSwitchMsg,
                               newtable=newtable)

        def switch_to_previous_table():
            newtable = self.grid.current_table - 1
            post_command_event(self.grid, self.GridActionTableSwitchMsg,
                               newtable=newtable)

        grid = self.grid
        actions = grid.actions

        shift, alt, ctrl = 1, 1 << 1, 1 << 2

        # Shortcuts key tuple: (modifier, keycode)
        # Modifier may be e. g. shift | ctrl

        shortcuts = {
            # <Esc> pressed
            (0, 27): lambda: setattr(actions, "need_abort", True),
            # <Del> pressed
            (0, 127): actions.delete,
            # <Home> pressed
            (0, 313): lambda: actions.set_cursor((grid.GetGridCursorRow(), 0)),
            # <Ctrl> + R pressed
            (ctrl, 82): actions.copy_selection_access_string,
            # <Ctrl> + + pressed
            (ctrl, 388): actions.zoom_in,
            # <Ctrl> + - pressed
            (ctrl, 390): actions.zoom_out,
            # <Shift> + <Space> pressed
            (shift, 32): lambda: grid.SelectRow(grid.GetGridCursorRow()),
            # <Ctrl> + <Space> pressed
            (ctrl, 32): lambda: grid.SelectCol(grid.GetGridCursorCol()),
            # <Shift> + <Ctrl> + <Space> pressed
            (shift | ctrl, 32): grid.SelectAll,
        }

        if self.main_window.IsFullScreen():
            # <Arrow up> pressed
            shortcuts[(0, 315)] = switch_to_previous_table
            # <Arrow down> pressed
            shortcuts[(0, 317)] = switch_to_next_table
            # <Space> pressed
            shortcuts[(0, 32)] = switch_to_next_table

        keycode = event.GetKeyCode()

        modifier = shift * event.ShiftDown() | \
            alt * event.AltDown() | ctrl * event.ControlDown()

        if (modifier, keycode) in shortcuts:
            shortcuts[(modifier, keycode)]()

        else:
            event.Skip()
Handles non-standard shortcut events