KeyStateHandler Class

Inheritance diagram of KeyStateHandler

class KeyStateHandler

Simple handler that tracks the state of keys on the keyboard. If a key is pressed then this handler holds a True value for it.

For example:

>>> win = window.Window
>>> keyboard = key.KeyStateHandler()
>>> win.push_handlers(keyboard)

# Hold down the "up" arrow...

>>> keyboard[key.UP]
True
>>> keyboard[key.DOWN]
False

Methods:

clear(() -> None.  Remove all items from D.)
copy(() -> a shallow copy of D)
get((k[,d]) -> D[k] if k in D, ...)
has_key((k) -> True if D has a key k, else False)
items(() -> list of D’s (key, value) pairs, ...)
iteritems(() -> an iterator over the (key, ...)
iterkeys(() -> an iterator over the keys of D)
itervalues(...)
keys(() -> list of D’s keys)
on_key_press(symbol, modifiers)
on_key_release(symbol, modifiers)
pop((k[,d]) -> v, ...) If key is not found, d is returned if given, otherwise KeyError is raised
popitem(() -> (k, v), ...) 2-tuple; but raise KeyError if D is empty.
setdefault((k[,d]) -> D.get(k,d), ...)
update(([E, ...) If E present and has a .keys() method, does: for k in E: D[k] = E[k]
values(() -> list of D’s values)
viewitems(...)
viewkeys(...)
viewvalues(...)

Methods

KeyStateHandler.on_key_press(symbol, modifiers)
KeyStateHandler.on_key_release(symbol, modifiers)

Inherited members

Methods

KeyStateHandler.clear() → None. Remove all items from D.
KeyStateHandler.copy() → a shallow copy of D
KeyStateHandler.get(k[, d]) → D[k] if k in D, else d. d defaults to None.
KeyStateHandler.has_key(k) → True if D has a key k, else False
KeyStateHandler.items() → list of D's (key, value) pairs, as 2-tuples
KeyStateHandler.iteritems() → an iterator over the (key, value) items of D
KeyStateHandler.iterkeys() → an iterator over the keys of D
KeyStateHandler.itervalues() → an iterator over the values of D
KeyStateHandler.keys() → list of D's keys
KeyStateHandler.pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

KeyStateHandler.popitem() → (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

KeyStateHandler.setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
KeyStateHandler.update([E, ]**F) → None. Update D from dict/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

KeyStateHandler.values() → list of D's values
KeyStateHandler.viewitems() → a set-like object providing a view on D's items
KeyStateHandler.viewkeys() → a set-like object providing a view on D's keys
KeyStateHandler.viewvalues() → an object providing a view on D's values

Table Of Contents

Previous topic

user_key Function

Next topic

modifiers_string Function