KModifierKeyInfo

KDE 4.9 PyKDE API Reference

- KDE's Python API

# KModifierKeyInfo Class Reference

`from PyKDE4.kdeui import *`

Inherits: QObject

## Detailed Description

Get information about the state of the keyboard's modifier keys.

This class provides cross-platform information about the state of the keyboard's modifier keys and the mouse buttons and allows to change the state as well.

It recognizes two states a key can be in: <ul><li><i>locked</i>: eg. caps-locked (aka toggled)</li> <li><i>latched</i>: the key is temporarily locked but will be unlocked upon the next keypress.</li></ul>

An application can either query the states synchronously (@see isKeyLatched,

See also:
  isKeyLocked) or connect to KModifierKeyInfo's signals to be notified about changes (@see keyLatched,
  See also:
    keyLocked).

  ## Signals
  | buttonPressed (Qt::MouseButton button, bool pressed)
  | keyAdded (Qt::Key key)
  | keyLatched (Qt::Key key, bool latched)
  | keyLocked (Qt::Key key, bool locked)
  | keyPressed (Qt::Key key, bool pressed)
  | keyRemoved (Qt::Key key)
  ## Methods
  | __init__ (self, QObject parent=0)
  | __init__ (self, KModifierKeyInfo a0)
  bool | isButtonPressed (self, Qt::MouseButton button)
  bool | isKeyLatched (self, Qt::Key key)
  bool | isKeyLocked (self, Qt::Key key)
  bool | isKeyPressed (self, Qt::Key key)
  [Qt::Key] | knownKeys (self)
  bool | knowsKey (self, Qt::Key key)
  bool | setKeyLatched (self, Qt::Key key, bool latched)
  bool | setKeyLocked (self, Qt::Key key, bool locked)

  ## Signal Documentation

  buttonPressed | ( | Qt::MouseButton | button,
  |  | bool | pressed
  | ) |  |  |

  This signal is emitted whenever the pressed state of a mouse button changes (mouse button press or release).

  Parameters:

    | button | The mouse button that changed state
    | pressed | true if the mouse button is now pressed, false if is released.

  Signal syntax:
    `QObject.connect(source, SIGNAL("buttonPressed(Qt::MouseButton, bool)"), target_slot)`

  keyAdded | ( | Qt::Key | key
  | ) |  |  |

  This signal is emitted whenever a new modifier is found due to the keyboard mapping changing.

  Parameters:

    | key | The key that was discovered

  Signal syntax:
    `QObject.connect(source, SIGNAL("keyAdded(Qt::Key)"), target_slot)`

  keyLatched | ( | Qt::Key | key,
  |  | bool | latched
  | ) |  |  |

  This signal is emitted whenever the latched state of a key changes.

  Parameters:

    | key | The key that changed state
    | latched | true if the key is now latched, false if it isn't

  Signal syntax:
    `QObject.connect(source, SIGNAL("keyLatched(Qt::Key, bool)"), target_slot)`

  keyLocked | ( | Qt::Key | key,
  |  | bool | locked
  | ) |  |  |

  This signal is emitted whenever the locked state of a key changes.

  Parameters:

    | key | The key that changed state
    | locked | true if the key is now locked, false if it isn't

  Signal syntax:
    `QObject.connect(source, SIGNAL("keyLocked(Qt::Key, bool)"), target_slot)`

  keyPressed | ( | Qt::Key | key,
  |  | bool | pressed
  | ) |  |  |

  This signal is emitted whenever the pressed state of a key changes (key press or key release).

  Parameters:

    | key | The key that changed state
    | pressed | true if the key is now pressed, false if is released.

  Signal syntax:
    `QObject.connect(source, SIGNAL("keyPressed(Qt::Key, bool)"), target_slot)`

  keyRemoved | ( | Qt::Key | key
  | ) |  |  |

  This signal is emitted whenever a previously known modifier no longer exists due to the keyboard mapping changing.

  Parameters:

    | key | The key that vanished

  Signal syntax:
    `QObject.connect(source, SIGNAL("keyRemoved(Qt::Key)"), target_slot)`

  ## Method Documentation

  __init__ | ( | self, |
  |  | QObject | parent=0
  | ) |  |  |

  Default constructor

  __init__ | ( | self, |
  |  | KModifierKeyInfo | a0
  | ) |  |  |

  bool isButtonPressed | ( | self, |
  |  | Qt::MouseButton | button
  | ) |  |  |

  Synchronously check if a mouse button is pressed.

  Parameters:

    | button | The mouse button to check

  Returns:
    true if the mouse button is pressed, false if the mouse button is not pressed or its state is unknown.

  bool isKeyLatched | ( | self, |
  |  | Qt::Key | key
  | ) |  |  |

  Synchronously check if a key is latched.

  Parameters:

    | key | The key to check

  Returns:
    true if the key is latched, false if the key is not latched or unknown.
  See also:
    isKeyPressed,
    See also:
      isKeyLocked,
      See also:
        keyLatched

  bool isKeyLocked | ( | self, |
  |  | Qt::Key | key
  | ) |  |  |

  Synchronously check if a key is locked.

  Parameters:

    | key | The key to check

  Returns:
    true if the key is locked, false if the key is not locked or unknown.
  See also:
    isKeyPressed,
    See also:
      isKeyLatched,
      See also:
        keyLocked

  bool isKeyPressed | ( | self, |
  |  | Qt::Key | key
  | ) |  |  |

  Synchronously check if a key is pressed.

  Parameters:

    | key | The key to check

  Returns:
    true if the key is pressed, false if the key is not pressed or unknown.
  See also:
    isKeyLatched,
    See also:
      isKeyLocked,
      See also:
        keyPressed

  [Qt::Key] knownKeys | ( |  | self ) |

  Get a list of known keys.

  Returns:
    A list of known keys of which states will be reported.

  bool knowsKey | ( | self, |
  |  | Qt::Key | key
  | ) |  |  |

  Check if a key is known by the underlying window system and can be queried.

  Parameters:

    | key | The key to check

  Returns:
    true if the key is available, false if it is unknown

  bool setKeyLatched | ( | self, |
  |  | Qt::Key | key,
  |  | bool | latched
  | ) |  |  |

  Set the latched state of a key.

  Parameters:

    | key | The key to latch
    | latched | true to latch the key, false to unlatch it.

  Returns:
    false if the key is unknown. true doesn't guarantee you the operation worked.

  bool setKeyLocked | ( | self, |
  |  | Qt::Key | key,
  |  | bool | locked
  | ) |  |  |

  Set the locked state of a key.

  Parameters:

    | key | The key to lock
    | latched | true to lock the key, false to unlock it.

  Returns:
    false if the key is unknown. true doesn't guarantee you the operation worked.