2024-07-07 12:27:18 +02:00
|
|
|
import string
|
|
|
|
class keyboard:
|
|
|
|
def __init__(self, canvas):
|
|
|
|
tkeys = list(string.ascii_letters)
|
|
|
|
self._keys = {}
|
|
|
|
for i in tkeys:
|
|
|
|
self._keys[i] = False
|
2024-07-28 16:43:05 +02:00
|
|
|
canvas.bind("<KeyPress>", self.keypupd, add="+")
|
|
|
|
canvas.bind("<KeyRelease>", self.keydupd, add="+")
|
2024-07-07 12:27:18 +02:00
|
|
|
|
|
|
|
def keypupd(self, event):
|
|
|
|
event = event.char
|
|
|
|
if event in self._keys:
|
|
|
|
self._keys[event] = True
|
|
|
|
|
|
|
|
def keydupd(self, event):
|
|
|
|
event = event.char
|
|
|
|
if event in self._keys:
|
|
|
|
self._keys[event] = False
|
|
|
|
|
|
|
|
def getkeys(self):
|
2024-07-28 16:43:05 +02:00
|
|
|
return self._keys
|