-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeys.py
31 lines (26 loc) · 861 Bytes
/
keys.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from hpprime import keyboard
class Keys:
def __init__(self):
self.keyboard_input = keyboard()
self.left = 7
self.right = 8
self.up = 2
self.down = 12
def just_pressed(self, key):
if self.old_keyboard_input & (1 << key) == False and self.keyboard_input & (1 << key) != False:
return True
else:
return False
def just_released(self, key):
if self.old_keyboard_input & (1 << key) != False and self.keyboard_input & (1 << key) == False:
return True
else:
return False
def is_pressed(self, key):
if self.keyboard_input & (1 << key) != False:
return True
else:
return False
def get(self):
self.old_keyboard_input = self.keyboard_input
self.keyboard_input = keyboard()