Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit703409e

Browse files
committed
update control keyboard tutorial
1 parente22de4a commit703409e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

‎general/keyboard-controller/control_keyboard.py‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,21 @@
1010
# check if a ctrl is pressed
1111
print(keyboard.is_pressed('ctrl'))
1212

13-
# press space
13+
# pressand releasespace
1414
keyboard.send("space")
1515

16+
# multi-key, windows+d as example shows the desktop in Windows machines
17+
keyboard.send("windows+d")
18+
19+
# send ALT+F4 in the same time, and then send space,
20+
# (be carful, this will close any current open window)
21+
keyboard.send("alt+F4, space")
22+
23+
# press CTRL button
24+
keyboard.press("ctrl")
25+
# release the CTRL button
26+
keyboard.release("ctrl")
27+
1628
# sends artificial keyboard events to the OS
1729
# simulating the typing of a given text
1830
# setting 0.1 seconds to wait between keypresses to look fancy
@@ -22,6 +34,11 @@
2234
events=keyboard.record('esc')
2335
# play these events
2436
keyboard.play(events)
37+
# print all typed strings in the events
38+
print(list(keyboard.get_typed_strings(events)))
39+
40+
# log all pressed keys
41+
keyboard.on_release(lambdae:print(e.name))
2542

2643
# remove all keyboard hooks in use
2744
keyboard.unhook_all()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp