Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 519a657156f8292188a5d8f560aa6169 > files > 22

pygame-doc-1.8.1-4mdv2010.0.i586.rpm


<html>
<title>key - Pygame Documentation</title>
<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>


<table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
<tr>
<td bgcolor='#c2fc20' style='padding: 6px;' align=center valign=center><a href='http://www.pygame.org/'><img src='../pygame_tiny.gif' border=0 width=200 height=60></a><br><b>pygame documentation</b></td>
<td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
	||&nbsp;
	<a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
	<a href=../index.html>Help Contents</a> &nbsp;||
	<a href=index.html>Reference Index</a> &nbsp;||
	<br>&nbsp;<br>
	
<a href="cdrom.html">Cdrom</a>&nbsp;||&nbsp;
<a href="color.html">Color</a>&nbsp;||&nbsp;
<a href="cursors.html">Cursors</a>&nbsp;||&nbsp;
<a href="display.html">Display</a>&nbsp;||&nbsp;
<a href="draw.html">Draw</a>&nbsp;||&nbsp;
<a href="event.html">Event</a>&nbsp;||&nbsp;
<a href="font.html">Font</a>&nbsp;||&nbsp;
<a href="image.html">Image</a>&nbsp;||&nbsp;
<a href="joystick.html">Joystick</a>&nbsp;||&nbsp;
<a href="key.html">Key</a>&nbsp;||&nbsp;
<a href="mask.html">Mask</a>&nbsp;||&nbsp;
<a href="mixer.html">Mixer</a>&nbsp;||&nbsp;
<a href="mouse.html">Mouse</a>&nbsp;||&nbsp;
<a href="movie.html">Movie</a>&nbsp;||&nbsp;
<a href="music.html">Music</a>&nbsp;||&nbsp;
<a href="overlay.html">Overlay</a>&nbsp;||&nbsp;
<a href="pixelarray.html">Pixelarray</a>&nbsp;||&nbsp;
<a href="pygame.html">Pygame</a>&nbsp;||&nbsp;
<a href="rect.html">Rect</a>&nbsp;||&nbsp;
<a href="scrap.html">Scrap</a>&nbsp;||&nbsp;
<a href="sndarray.html">Sndarray</a>&nbsp;||&nbsp;
<a href="sprite.html">Sprite</a>&nbsp;||&nbsp;
<a href="surface.html">Surface</a>&nbsp;||&nbsp;
<a href="surfarray.html">Surfarray</a>&nbsp;||&nbsp;
<a href="time.html">Time</a>&nbsp;||&nbsp;
<a href="transform.html">Transform</a>
</td></tr></table>
<br>


<a name="pygame.key">
<big><b>pygame.key</big></b><br><ul>
  <i>pygame module to work with the keyboard</i><br>
<ul><small><table>
  <tr><td><a href="key.html#pygame.key.get_focused">pygame.key.get_focused</a> - <font size=-1>true if the display is receiving keyboard input from the system</font></td><td>true if the display is receiving keyboard input from the system</td></tr>
  <tr><td><a href="key.html#pygame.key.get_pressed">pygame.key.get_pressed</a> - <font size=-1>get the state of all keyboard buttons</font></td><td>get the state of all keyboard buttons</td></tr>
  <tr><td><a href="key.html#pygame.key.get_mods">pygame.key.get_mods</a> - <font size=-1>determine which modifier keys are being held</font></td><td>determine which modifier keys are being held</td></tr>
  <tr><td><a href="key.html#pygame.key.set_mods">pygame.key.set_mods</a> - <font size=-1>temporarily set which modifier keys are pressed</font></td><td>temporarily set which modifier keys are pressed</td></tr>
  <tr><td><a href="key.html#pygame.key.set_repeat">pygame.key.set_repeat</a> - <font size=-1>control how held keys are repeated</font></td><td>control how held keys are repeated</td></tr>
  <tr><td><a href="key.html#pygame.key.get_repeat">pygame.key.get_repeat</a> - <font size=-1>see how held keys are repeated</font></td><td>see how held keys are repeated</td></tr>
  <tr><td><a href="key.html#pygame.key.name">pygame.key.name</a> - <font size=-1>get the name of a key identifier</font></td><td>get the name of a key identifier</td></tr>
</table></small></ul>
<p>This module contains functions for dealing with the keyboard. </p>
<p>The event queue gets <tt>pygame.KEYDOWN</tt> and <tt>pygame.KEYUP</tt> events when the keyboard buttons are pressed and released. Both events have a key attribute that is a integer id representing every key on the keyboard. </p>
<p>The <tt>pygame.KEYDOWN</tt> event has an additional attributes unicode, and scancode. unicode represents a single character string that is the fully translated character entered. This takes into account the shift and composition keys. scancode represents the platform specific key code. This could be different from keyboard to keyboard, but is useful for key selection of weird keys like the multimedia keys. </p>
<p>There are many keyboard constants, they are used to represent keys on the keyboard. The following is a list of all keyboard constants </p>
<pre>      KeyASCII      ASCII   Common Name
      K_BACKSPACE   \b      backspace
      K_TAB         \t      tab
      K_CLEAR               clear
      K_RETURN      \r      return
      K_PAUSE               pause
      K_ESCAPE      ^[      escape
      K_SPACE               space
      K_EXCLAIM     !       exclaim
      K_QUOTEDBL    "       quotedbl
      K_HASH        #       hash
      K_DOLLAR      $       dollar
      K_AMPERSAND   &       ampersand
      K_QUOTE               quote
      K_LEFTPAREN   (       left parenthesis
      K_RIGHTPAREN  )       right parenthesis
      K_ASTERISK    *       asterisk
      K_PLUS        +       plus sign
      K_COMMA       ,       comma
      K_MINUS       -       minus sign
      K_PERIOD      .       period
      K_SLASH       /       forward slash
      K_0           0       0
      K_1           1       1
      K_2           2       2
      K_3           3       3
      K_4           4       4
      K_5           5       5
      K_6           6       6
      K_7           7       7
      K_8           8       8
      K_9           9       9
      K_COLON       :       colon
      K_SEMICOLON   ;       semicolon
      K_LESS        <       less-than sign
      K_EQUALS      =       equals sign
      K_GREATER     >       greater-than sign
      K_QUESTION    ?       question mark
      K_AT          @       at
      K_LEFTBRACKET [       left bracket
      K_BACKSLASH   \       backslash
      K_RIGHTBRACKET ]      right bracket
      K_CARET       ^       caret
      K_UNDERSCORE  _       underscore
      K_BACKQUOTE   `       grave
      K_a           a       a
      K_b           b       b
      K_c           c       c
      K_d           d       d
      K_e           e       e
      K_f           f       f
      K_g           g       g
      K_h           h       h
      K_i           i       i
      K_j           j       j
      K_k           k       k
      K_l           l       l
      K_m           m       m
      K_n           n       n
      K_o           o       o
      K_p           p       p
      K_q           q       q
      K_r           r       r
      K_s           s       s
      K_t           t       t
      K_u           u       u
      K_v           v       v
      K_w           w       w
      K_x           x       x
      K_y           y       y
      K_z           z       z
      K_DELETE              delete
      K_KP0                 keypad 0
      K_KP1                 keypad 1
      K_KP2                 keypad 2
      K_KP3                 keypad 3
      K_KP4                 keypad 4
      K_KP5                 keypad 5
      K_KP6                 keypad 6
      K_KP7                 keypad 7
      K_KP8                 keypad 8
      K_KP9                 keypad 9
      K_KP_PERIOD   .       keypad period
      K_KP_DIVIDE   /       keypad divide
      K_KP_MULTIPLY *       keypad multiply
      K_KP_MINUS    -       keypad minus
      K_KP_PLUS     +       keypad plus
      K_KP_ENTER    \r      keypad enter
      K_KP_EQUALS   =       keypad equals
      K_UP                  up arrow
      K_DOWN                down arrow
      K_RIGHT               right arrow
      K_LEFT                left arrow
      K_INSERT              insert
      K_HOME                home
      K_END                 end
      K_PAGEUP              page up
      K_PAGEDOWN            page down
      K_F1                  F1
      K_F2                  F2
      K_F3                  F3
      K_F4                  F4
      K_F5                  F5
      K_F6                  F6
      K_F7                  F7
      K_F8                  F8
      K_F9                  F9
      K_F10                 F10
      K_F11                 F11
      K_F12                 F12
      K_F13                 F13
      K_F14                 F14
      K_F15                 F15
      K_NUMLOCK             numlock
      K_CAPSLOCK            capslock
      K_SCROLLOCK           scrollock
      K_RSHIFT              right shift
      K_LSHIFT              left shift
      K_RCTRL               right ctrl
      K_LCTRL               left ctrl
      K_RALT                right alt
      K_LALT                left alt
      K_RMETA               right meta
      K_LMETA               left meta
      K_LSUPER              left windows key
      K_RSUPER              right windows key
      K_MODE                mode shift
      K_HELP                help
      K_PRINT               print screen
      K_SYSREQ              sysrq
      K_BREAK               break
      K_MENU                menu
      K_POWER               power
      K_EURO                euro
</pre><p>The keyboard also has a list of modifier states that can be assembled bit bitwise ORing them together. </p>
<pre>      KMOD_NONE, KMOD_LSHIFT, KMOD_RSHIFT, KMOD_SHIFT, KMOD_CAPS,
      KMOD_LCTRL, KMOD_RCTRL, KMOD_CTRL, KMOD_LALT, KMOD_RALT,
      KMOD_ALT, KMOD_LMETA, KMOD_RMETA, KMOD_META, KMOD_NUM, KMOD_MODE
</pre>
<!--COMMENTS:pygame.key--> &nbsp;<br> 


<a name="pygame.key.get_focused">
<big><b>pygame.key.get_focused</big></b><br><ul>
  <i>true if the display is receiving keyboard input from the system</i><br>
  <tt>pygame.key.get_focused(): return bool</tt><br>
<p>This is true when the display window has keyboard focus from the system. If the display needs to ensure it does not lose keyboard focus, it can use <tt><a href="event.html#pygame.event.set_grab">pygame.event.set_grab</a> - <font size=-1>control the sharing of input devices with other applications</font></tt> to grab all input. </p>
<!--COMMENTS:pygame.key.get_focused--> &nbsp;<br> 
<br></ul>


<a name="pygame.key.get_pressed">
<big><b>pygame.key.get_pressed</big></b><br><ul>
  <i>get the state of all keyboard buttons</i><br>
  <tt>pygame.key.get_pressed(): return bools</tt><br>
<p>Returns a sequence of boolean values representing the state of every key on the keyboard. Use the key constant values to index the array. <tt>A</tt> True value means the that button is pressed. </p>
<p>Getting the list of pushed buttons with this function is not the proper way to handle text entry from the user. You have no way to know the order of keys pressed, and rapidly pushed keys can be completely unnoticed between two calls to <tt><a href="key.html#pygame.key.get_pressed">pygame.key.get_pressed</a> - <font size=-1>get the state of all keyboard buttons</font></tt>. There is also no way to translate these pushed keys into a fully translated character value. See the <tt>pygame.KEYDOWN</tt> events on the event queue for this functionality. </p>
<!--COMMENTS:pygame.key.get_pressed--> &nbsp;<br> 
<br></ul>


<a name="pygame.key.get_mods">
<big><b>pygame.key.get_mods</big></b><br><ul>
  <i>determine which modifier keys are being held</i><br>
  <tt>pygame.key.get_mods(): return int</tt><br>
<p>Returns a single integer representing a bitmask of all the modifier keys being held. Using bitwise operators you can test if specific shift keys are pressed, the state of the capslock button, and more. </p>
<!--COMMENTS:pygame.key.get_mods--> &nbsp;<br> 
<br></ul>


<a name="pygame.key.set_mods">
<big><b>pygame.key.set_mods</big></b><br><ul>
  <i>temporarily set which modifier keys are pressed</i><br>
  <tt>pygame.key.set_mods(int): return None</tt><br>
<p>Create a bitmask of the modifier constants you want to impose on your program. </p>
<!--COMMENTS:pygame.key.set_mods--> &nbsp;<br> 
<br></ul>


<a name="pygame.key.set_repeat">
<big><b>pygame.key.set_repeat</big></b><br><ul>
  <i>control how held keys are repeated</i><br>
  <tt>pygame.key.set_repeat(): return None</tt><br>
  <tt>pygame.key.set_repeat(delay, interval): return None</tt><br>
<p>When the keyboard repeat is enabled, keys that are held down will generate multiple <tt>pygame.KEYDOWN</tt> events. The delay is the number of milliseconds before the first repeated <tt>pygame.KEYDOWN</tt> will be sent. After that another <tt>pygame.KEYDOWN</tt> will be sent every interval milliseconds. If no arguments are passed the key repeat is disabled. </p>
<p>When pygame is initialized the key repeat is disabled. </p>
<!--COMMENTS:pygame.key.set_repeat--> &nbsp;<br> 
<br></ul>


<a name="pygame.key.get_repeat">
<big><b>pygame.key.get_repeat</big></b><br><ul>
  <i>see how held keys are repeated</i><br>
  <tt>pygame.key.get_repeat(): return (delay, interval)</tt><br>
<p>When the keyboard repeat is enabled, keys that are held down will generate multiple <tt>pygame.KEYDOWN</tt> events. The delay is the number of milliseconds before the first repeated <tt>pygame.KEYDOWN</tt> will be sent. After that another <tt>pygame.KEYDOWN</tt> will be sent every interval milliseconds. </p>
<p>When pygame is initialized the key repeat is disabled. </p>
<p>New in pygame <tt>1.8</tt>. </p>
<!--COMMENTS:pygame.key.get_repeat--> &nbsp;<br> 
<br></ul>


<a name="pygame.key.name">
<big><b>pygame.key.name</big></b><br><ul>
  <i>get the name of a key identifier</i><br>
  <tt>pygame.key.name(key): return string</tt><br>
<p>Get the descriptive name of the button from a keyboard button id constant. </p>
<!--COMMENTS:pygame.key.name--> &nbsp;<br> 
<br></ul>
<br></ul>

</body></html>