From: Bruce S. <Bru...@nc...> - 2012-04-27 16:41:24
|
Since your program works normally for me, I'm wondering whether you mean that you expected to get diagonal motion with both keys held down? There isn't currently any way to detect multiple simultaneous keys in VPython (other than combinations with shift, ctrl, or alt, of course). As for the delay before repeating starts, I think that's a feature of most computer systems, intended to prevent unwanted repetition when you finger lingers just a bit too long on a key. You have to hold the key down long enough to convince the operating system that you really do want repetition. Bruce Sherwood On Fri, Apr 27, 2012 at 6:43 AM, Akasei Yoshiko <ak...@in...> wrote: > How i can chack if key is pressed? > Or when I press arrow Left and arrow Up my "ball" move only in one > direction. > > >> # -*- coding: UTF-8 -*- >> from visual import * >> >> scene = display( title='Przykład', x=0, y=0, width=640, height=480, >> center=( 0, 0, 0 ), background=( 0, 0, 0 ), fov=1.0 ) >> ball = sphere( pos=( 0, 0, 0 ), radius=0.5 ) >> >> scene.autoscale = False >> scene.range=( 10, 10, 10 ) >> >> while True: >> if scene.kb.keys: >> key = scene.kb.getkey() >> if key == 'right': >> ball.pos.x += 1 >> if key == 'left': >> ball.pos.x -= 1 >> if key == 'up': >> ball.pos.y += 1 >> if key == 'down': >> ball.pos.y -= 1 > > |