4
Okay, I edited the question, this is the most simplified example, I wish that while the '6' key is being pressed, even using the '8' key, it continues to interact with the program, while '8' only executes one command and does not interrupt the other.
#from Tkinter import Tk, Canvas, Frame
Tela_principal = Tk()
Tela_principal.geometry('1024x720+10+10')
def aplicacao():
area_1.place(x=0, y=0), area_2.place(x=3, y=150)
fundo_area2.place(x=10, y=10)
persona()
def execucao():
Tela_principal.bind("<KeyPress-8>", controles)
Tela_principal.bind("<KeyPress-5>", controles)
Tela_principal.bind("<KeyPress-6>", controles)
Tela_principal.bind("<KeyPress-4>", controles)
fundo_area2.delete('personagem')
persona()
area_2.after(FPS, execucao)
def persona():
boneco_tronco_Lateral = fundo_area2.create_polygon(
[(2 + x, 25 + y), (20 + x, 25 + y), (20 + x, 152 + y), (2 + x, 152 + y)],
fill=pele, outline='black', tag='personagem')
def controles(event):
global x, y, velocidade_x, velocidade_y
if event.char == '6':
x += velocidade_x
fundo_area2.move('personagem', velocidade_x, 0)
if event.char == '4':
x -= velocidade_x
fundo_area2.move('personagem', -velocidade_x, 0)
if event.char == '8' and '6':
y -= velocidade_y
x += velocidade_x
fundo_area2.move('personagem', -velocidade_x, 0)
area_1 = Frame(bg='snow', height=100, width=780, cursor='cross')
fundo_area1 = Canvas(area_1, bg='plum4', height=43, width=620)
area_2 = Frame(bg='snow', height=500, width=1016, cursor='dotbox')
fundo_area2 = Canvas(area_2, bg='gray', height=642, width=973)
x = 0
y = 100
pele = 'tomato'
velocidade_x = 0.5
velocidade_y = 0.5
FPS = 5
cont_salto = 0
aplicacao(), execucao()
Tela_principal.mainloop()
###########Thanks!!
Could you make a minimum replicable example? See instructions here: https://answall.com/help/minimal-reproducible-example
– Lucas
Sure, I’ll post a new, more simplified example.
– KARPSS