当前位置:网站首页>[pyGame learning notes] 7 event
[pyGame learning notes] 7 event
2022-07-19 13:04:00 【Leleprogrammer】
From the front 6 In the study notes , It's not hard to see , We always have to Game writes listen Event listening method , This is a study note , Let's learn more Pygame Event monitoring of requires pygame Constant
pygame Constants are stored in pygame.locals Module , We can import
from pygame.locals import *
here , I put some commonly used pygame The event constants and uses are summarized in the following table , For your reference ( The corresponding values may be different in different versions , my pygame The version is 2.1.2)
Constant | ASCII | explain |
---|---|---|
K_BACKSPACE | \b | Backspace |
K_TAB | \t | tab |
K_RETURN | \r | enter |
K_PAUSE | Pause | |
K_ESCAPE | ^[ | ESC Key |
K_SPACE | Space | |
K_ASTERISK | * | asterisk |
K_PLUS | + | plus |
K_MINUS | - | minus sign |
K_COMMA | , | comma |
K_PERIOD | . | Full stop |
K_SLASH | / | 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_EXCLAIM | ! | Exclamatory mark |
K_QUOTEDBL | " | quotes |
K_HASH | # | Well No |
K_DOLLAR | $ | Dollar symbol |
K_AMPERSAND | & | & Symbol |
K_LEFTPAREN | ( | Left parenthesis |
K_RIGHTPAREN | ) | Right bracket |
K_COLON | : | The colon |
K_SEMICOLON | ; | A semicolon |
K_LESS | < | Less than no. |
K_EQUALS | = | be equal to |
K_GREATER | > | More than no. |
K_QUESTION | ? | question mark |
K_AT | @ | @ Symbol |
K_LEFTBRACKET | [ | Left bracket |
K_RIGHTBRACKET | ] | Right bracket |
K_BACKSLASH | \ | The backslash |
K_CARET | ^ | ^ Symbol |
K_UNDERSCORE | _ | Underline |
K_BACKQUOTE | ` | Order number |
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 Delete key | |
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 . |
K_KP_DIVIDE | / | Keypad / |
K_KP_MULTIPLY | * | Keypad * |
K_KP_MINUS | - | Keypad - |
K_KP_PLUS | + | Keypad + |
K_KP_ENTER | \r | Keypad Enter |
K_KP_EQUALS | = | Keypad = |
K_UP | Direction key ↑ | |
K_DOWN | Direction key ↓ | |
K_LEFT | Direction key ← | |
K_RIGHT | Direction key → | |
K_INSERT | Insert Key | |
K_HOME | Home Key | |
K_END | End Key | |
K_PAGEUP | Page up key | |
K_PAGEDOWN | Page down key | |
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 | Numeric keypad lock | |
K_CAPSLOCK | Caps lock | |
K_SCROLLOCK | Roller lock | |
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_LSUPER | Left Windows Winkey | |
K_RSUPER | Right Windows Winkey |
Then there are some pygame.key Here are some common methods :
pygame.key.get_focused() ->bool
If the user's keyboard input is being accepted, then true
pygame.key.get_pressed()
Return to one bool Sequence of values , Indicates the status of each key on the keyboard , Use key constant values to index arrays , value True Indicates being pressed
pygame.key.get_mods()
Returns an integer , Represents the bitmask of all modification keys , Use bitwise operators , You can test whether a specific modifier key is pressed
pygame.key.set_mods()
Temporarily set which modifier keys are pressed
pygame.key.set_repeat( Delay , interval )
Control the repetition of keys
When keyboard repetition is enabled , Pressing and holding the key will generate multiple pygame.KEYDOWN
event . The delay
Parameter is pygame.KEYDOWN
The number of milliseconds before sending the first repeating event . after ,pygame.KEYDOWN
Will each interval
Send another event in milliseconds . If a value is provided but not delay
One interval
Value or 0, be interval
Set to and The same value delay
.
To disable key repetition, call this function , Without parameters or delay
Set to 0.
If the delay and interval parameters are less than zero , Throw out ValueError
pygame.key.get_repeat()
Get the duplicate value of the key
pygame.key.name( Keyboard button id Constant )
Returns a string , From the keyboard button id Get the descriptive name of the button in the constant
pygame.key.key_code(name)
Pass in the descriptive name of the button , Return to keyboard button id Constant
The above is pygame Some knowledge of event monitoring
It's not easy to make , If you like, just like the collection + Pay attention to ~
Thank you for your support ~
边栏推荐
- 国产API工具哪家强?原来是它…
- 最小交換次數
- S32K148_ Can drive (bare metal development)
- Return to risk ratio: the most important indicator of investment opportunities 2020-03-14
- The difference and use between get request and post request
- MOF customized material | NH (2) -uio66/rgo Graphene Oxide Nanocomposite | methylene blue loaded zif-90 nanoparticles
- Metal organic framework material / polymer composite zif-8/p (TDA co HDA) | zinc oxide [email protected] (FE) composite nan
- Opencv:06 morphology
- 運維小白成長記—架構第6周
- 506. Relative ranking
猜你喜欢
[email protected] )|Rhodamine 6G modified MOF material | catalase @zif composite | MOF"/>
Lanthanide metal organic skeleton( [email protected] )|Rhodamine 6G modified MOF material | catalase @zif composite | MOF
标签球问题
Uio-66 - (COOH) 2 modified polyamide nanofiltration membrane | zif-8/pvp composite nanofiber membrane | uio-66-nh2 modified polyamide nanofiltration membrane
2022 global developer salary exposure: China ranks 19th, with an average annual salary of $23790
Audio common terminal anatomy - never make a mistake again
About the "bottom reading" mentality, it makes you exhausted 2020-03-15
Do you still need to release the database connection manually with typeorm
可视化ETL工具Kettle概念、安装及实战案例
S32K148_ Can drive (bare metal development)
Azkaban installation documentation
随机推荐
VMware导入ova/ovf虚拟机文件
Flask源码分析(三):上下文
力扣70-爬楼梯——动态规划
2022 global developer salary exposure: China ranks 19th, with an average annual salary of $23790
Enrollment publicity - Jiangnan University
又错了,字节对齐及#pragma pack的使用
Knowledge sorting of MySQL
Cadmium sulfide supported mil-125 (TI) | streptavidin (SA) - zirconium porphyrin MOF composite (PCN- [email protected] )|Shell core
Brief analysis of circuit fault
ASP. Net collaborative OA office service management platform source code
Common bug precautions of audio control
If you merge cells by Excel, export excelutils
RingBuffer
LeetCode 0117. 填充每个节点的下一个右侧节点指针 II
npm err! [email protected] build: `umi build`
How can MySQL delete data tables and associated data tables
二叉树2—对称性递归问题
时序逻辑与组合逻辑的reg
[C language programming 8] branch predictor
The difference and use between get request and post request