Package pygsear :: Module Event :: Class KEY_Event
[show private | hide private]
[frames | no frames]

Class KEY_Event

object --+        
         |        
    Sprite --+    
             |    
         Event --+
                 |
                KEY_Event

Known Subclasses:
Repeat_KEY_Event, KEYUP_Event, KEYDOWN_Event

Keyboard events.
Method Summary
  __init__(self, type, key, callback, on_press, on_hold, on_release, **kwargs)
Initialize a keyboard event.
a new object with type S, a subtype of T __new__(S, ...)
  __repr__(self)
(inherited from Sprite)
  add(self, group)
Add this Event to an EventGroup. (inherited from Event)
  add_internal(self, group)
(inherited from Sprite)
  alive(self)
alive() -> bool ask the life of a sprite (inherited from Sprite)
  call(self, pygame_event, **kwargs)
Perform the callback, if the event is enabled, and the key pressed is the right key.
  check_holding(self, ev, **kwargs)
  disable(self)
Do not allow callbacks to go through. (inherited from Event)
  enable(self)
Allow callbacks to go through. (inherited from Event)
  groups(self)
groups() -> list list used sprite containers (inherited from Sprite)
  kill(self)
kill() end life of sprite, remove from all groups (inherited from Sprite)
  nop(self, ev, **kwargs)
Do nothing. (inherited from Event)
  press(self, ev, **kwargs)
  release(self, ev, **kwargs)
  remove(self, group)
remove(group) remove a sprite from container (inherited from Sprite)
  remove_internal(self, group)
(inherited from Sprite)
  update(self, *args)
(inherited from Sprite)

Method Details

__init__(self, type=-2, key=None, callback=None, on_press=None, on_hold=None, on_release=None, **kwargs)
(Constructor)

Initialize a keyboard event.
Parameters:
type - pygame.event type. Should be KEYDOWN or KEYUP
key - The keyboard key which will trigger this event, or a sequence of keys. (ie: Pressing any one of these keys will trigger the event) If key is None then any keypress will fire the callback.
callback - Function or method to call when the event occurs.
on_press - Function to call when key is first pressed
on_hold - Function to call while key is being held down. Will be called once for each pass through the game's mainloop. I am not yet convinced that on_hold is going to be useful at all.
on_release - Function to call when key is finally released
kwargs - Additional parameters that should be passed on to the callback.

__new__(S, ...)

Returns:
a new object with type S, a subtype of T

call(self, pygame_event, **kwargs)

Perform the callback, if the event is enabled, and the key pressed is the right key.
Parameters:
pygame_event - The actual pygame.event.Event that triggered this Event.
kwargs - Additional parameters that should be passed on to the callback. Note that keyword args included here will overwrite those added at the creation of the event.

Generated by Epydoc 1.1 on Sun Jan 25 19:10:13 2004 http://epydoc.sf.net