Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Background-Typingtest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stephen D
Background-Typingtest
Commits
118c7099
Commit
118c7099
authored
6 years ago
by
Stephen D
Browse files
Options
Downloads
Patches
Plain Diff
Added code
parent
a499f9bc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.py
+43
-0
43 additions, 0 deletions
main.py
with
43 additions
and
0 deletions
main.py
0 → 100644
+
43
−
0
View file @
118c7099
import
pyxhook
import
time
timer
=
None
last_press
=
None
total_time
=
0
total_words
=
0
def
OnKeyPress
(
event
):
global
timer
global
last_press
global
total_time
global
total_words
if
event
.
Ascii
>
65
and
event
.
Ascii
<
122
:
if
timer
is
None
:
timer
=
time
.
time
()
last_press
=
time
.
time
()
elif
time
.
time
()
-
last_press
<=
1
:
last_press
=
time
.
time
()
#Reset timer
else
:
#Reset word count
words
=
1
timer
=
None
elif
(
event
.
Key
==
"
Return
"
or
chr
(
event
.
Ascii
)
==
'
'
)
and
timer
is
not
None
:
#Calculate wpm
deltaT
=
time
.
time
()
-
timer
print
(
"
Typed 1 word in
"
+
str
(
deltaT
)
+
"
seconds.
"
)
print
(
str
(
60
/
deltaT
)
+
"
wpm.
"
)
total_time
+=
deltaT
total_words
+=
1
print
(
"
Avg:
"
+
str
(
total_words
*
60
/
total_time
))
timer
=
None
h
=
pyxhook
.
HookManager
()
h
.
KeyDown
=
OnKeyPress
h
.
HookKeyboard
()
h
.
start
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment