Re: Keyboard Interactions

Bruce Sherwood <[email protected]> Fri, 27 Apr 2012 10:41:11 -0600
Newsgroups gmane.comp.python.visualpython.user
Message-ID <CAFDG03iGoan2K+szZEHCVo=mOY6jgG0dMk1-FciZ1PAtogOTdg@mail.gmail.com>
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 <[email protected]> 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
>
>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Visualpython-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/visualpython-users