Posts: 544
Threads: 15
Joined: Oct 2016
Try with all keys binding to the canvas not root window.
99 percent of computer problems exists between chair and keyboard.
Posts: 544
Threads: 15
Joined: Oct 2016
Try changes arrows keys wasd.
# moving ship
if Game.keys_press.get('a', False):
Game.canvas.move(Game.ship, -Game.ship_speed, 0)
if Game.keys_press.get('d', False):
Game.canvas.move(Game.ship, Game.ship_speed, 0)
if Game.keys_press.get('w', False):
Game.canvas.move(Game.ship, 0, -Game.ship_speed)
if Game.keys_press.get('s', False):
Game.canvas.move(Game.ship, 0, Game.ship_speed)
if Game.keys_press.get('space', False):
if pauser_elaspe(Game.shoot_pauser, Game.ticks):
shoot()
99 percent of computer problems exists between chair and keyboard.
Posts: 544
Threads: 15
Joined: Oct 2016
Sounds like a keyboard error.
99 percent of computer problems exists between chair and keyboard.
Posts: 544
Threads: 15
Joined: Oct 2016
i use python 3.6. Arrows keys and wasd keys should work the same. So sound like need test with another keyboard. To see if you get same results.
I use this
PDF .
99 percent of computer problems exists between chair and keyboard.
Posts: 544
Threads: 15
Joined: Oct 2016
Here a small key press and release program example
import tkinter as tk
class App:
pass
def event_press(event):
if App.texts.get(event.keysym, False) is False:
App.texts[event.keysym] = tk.Label(App.frame, text='Key Press ' + event.keysym)
App.texts[event.keysym].pack()
else:
App.texts[event.keysym]['text'] = 'Key Press ' + event.keysym
def event_release(event):
# numlock
if event.keysym.startswith('KP') and event.char != '':
key = 'KP_' + event.char
else:
key = event.keysym
if App.texts.get(key, False):
App.texts[key]['text'] = 'Key Release ' + key
def main():
App.SCREEN_SIZE = {'w':600, 'h':400}
App.root = tk.Tk()
App.frame = tk.Frame(App.root, width=App.SCREEN_SIZE['w'], height=App.SCREEN_SIZE['h'])
App.frame.pack()
App.texts = {}
App.frame.bind_all('<KeyPress>', event_press)
App.frame.bind_all('<KeyRelease>', event_release)
App.root.mainloop()
if __name__ == '__main__':
main()
99 percent of computer problems exists between chair and keyboard.