A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://wxpython.org/Phoenix/docs/html/wx.KeyboardState.html below:

wx.KeyboardState — wxPython Phoenix 4.2.4a1 documentation

wx.KeyboardState¶

Provides methods for testing the state of the keyboard modifier keys.

This class is used as a base class of wx.KeyEvent and wx.MouseState and, hence, indirectly, of wx.MouseEvent, so its methods may be used to get information about the modifier keys which were pressed when the event occurred.

This class is implemented entirely inline in </kbdstate.h > and thus has no linking requirements.

Class Hierarchy¶

Inheritance diagram for class

KeyboardState

:

Known Subclasses¶

wx.KeyEvent, wx.MouseState

Methods Summary¶ Properties Summary¶ Class API¶
class wx.KeyboardState(object)¶

Possible constructors:

KeyboardState(controlDown=False, shiftDown=False, altDown=False,
              metaDown=False) -> None

Provides methods for testing the state of the keyboard modifier keys.


Methods¶
__init__(self, controlDown=False, shiftDown=False, altDown=False, metaDown=False)¶

Constructor initializes the modifier key settings.

By default, no modifiers are active.

Parameters:
  • controlDown (bool)

  • shiftDown (bool)

  • altDown (bool)

  • metaDown (bool)

Return type:

None


AltDown(self)¶

Returns True if the Alt key is pressed.

Notice that GetModifiers should usually be used instead of this one.

Return type:

bool


CmdDown(self)¶

Returns True if the key used for command accelerators is pressed.

Same as ControlDown . Deprecated.

Notice that GetModifiers should usually be used instead of this one.

Return type:

bool


ControlDown(self)¶

Returns True if the Control key or Apple/Command key under macOS is pressed.

This function doesn’t distinguish between right and left control keys.

Notice that GetModifiers should usually be used instead of this one.

Return type:

bool


GetModifiers(self)¶

Return the bit mask of all pressed modifier keys.

The return value is a combination of MOD_ALT , MOD_CONTROL , MOD_SHIFT and MOD_META bit masks. Additionally, MOD_NONE is defined as 0, i.e. corresponds to no modifiers (see HasAnyModifiers ) and MOD_CMD is either MOD_CONTROL (MSW and Unix) or MOD_META (Mac), see CmdDown . See wx.KeyModifier for the full list of modifiers.

Notice that this function is easier to use correctly than, for example, ControlDown because when using the latter you also have to remember to test that none of the other modifiers is pressed:

if ControlDown() and not AltDown() and not ShiftDown() and not MetaDown():
    # handle Ctrl-XXX ...
    HandleControl()

and forgetting to do it can result in serious program bugs (e.g. program not working with European keyboard layout where AltGr key which is seen by the program as combination of CTRL and ALT is used). On the other hand, you can simply write:

if GetModifiers() == wx.MOD_CONTROL:
    # handle Ctrl-XXX ...
    HandleControl()

with this function.

Return type:

int


HasAnyModifiers(self)¶

Returns True if any modifiers at all are pressed.

This is equivalent to GetModifiers != MOD_NONE .

Notice that this is different from HasModifiers method which doesn’t take e.g. Shift modifier into account. This method is most suitable for mouse events when any modifier, including Shift, can change the interpretation of the event.

Return type:

bool

Added in version 2.9.5.


HasModifiers(self)¶

Returns True if Control or Alt are pressed.

Checks if Control, Alt or, under macOS only, Command key are pressed (notice that the real Control key is still taken into account under OS X too).

This method returns False if only Shift is pressed for compatibility reasons and also because pressing Shift usually doesn’t change the interpretation of key events, see HasAnyModifiers if you want to take Shift into account as well.

Return type:

bool


MetaDown(self)¶

Returns True if the Meta/Windows/Apple key is pressed.

This function tests the state of the key traditionally called Meta under Unix systems, Windows keys under MSW Notice that GetModifiers should usually be used instead of this one.

Return type:

bool


RawControlDown(self)¶

Returns True if the Control key (also under macOS).

This function doesn’t distinguish between right and left control keys.

Notice that GetModifiers should usually be used instead of this one.

Return type:

bool


SetAltDown(self, down)¶
Parameters:

down (bool)

Return type:

None


SetControlDown(self, down)¶
Parameters:

down (bool)

Return type:

None


SetMetaDown(self, down)¶
Parameters:

down (bool)

Return type:

None


SetRawControlDown(self, down)¶
Parameters:

down (bool)

Return type:

None


SetShiftDown(self, down)¶
Parameters:

down (bool)

Return type:

None


ShiftDown(self)¶

Returns True if the Shift key is pressed.

This function doesn’t distinguish between right and left shift keys.

Notice that GetModifiers should usually be used instead of this one.

Return type:

bool


Properties¶
altDown¶

See AltDown and SetAltDown


cmdDown¶

See CmdDown


controlDown¶

See ControlDown and SetControlDown


metaDown¶

See MetaDown and SetMetaDown


rawControlDown¶

See RawControlDown and SetRawControlDown


shiftDown¶

See ShiftDown and SetShiftDown


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4