Skip to content

Commit c727e66

Browse files
committed
sampler example: Change from event.char to event.keysym
1 parent 50d4ea2 commit c727e66

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

examples/sampler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def update_rec_display(self, *args):
5252
self.rec_display['bg'] = REC_ON
5353

5454
def on_key_press(self, event):
55-
ch = event.char
56-
if ch.isupper():
55+
ch = event.keysym
56+
if len(ch) == 1 and ch.isupper():
5757
sample = self.samples[ch.lower()]
5858
if sample.action in self.stream.actions:
5959
return
@@ -72,7 +72,7 @@ def on_key_press(self, event):
7272

7373
def on_key_release(self, event):
7474
# NB: State of "shift" button may change between key press and release!
75-
ch = event.char.lower()
75+
ch = event.keysym.lower()
7676
if ch not in self.samples:
7777
return
7878
sample = self.samples[ch]
@@ -94,7 +94,7 @@ def on_key_release(self, event):
9494
# We might end up here if on_key_press() exits early
9595
pass
9696
else:
97-
assert False, (event.char, sample.action)
97+
assert False, (event.keysym, sample.action)
9898

9999
def poll_ringbuffer(self, sample):
100100
# Setting polling rate based on input latency (which may change!).

0 commit comments

Comments
 (0)