[IronPython] How to get Keyboard Input
Duong Vu
duong.v at gmail.com
Fri Aug 6 00:06:26 CEST 2010
Hi Andrew,
What the pay range on this? Unless its insane, I think I'll pass. I
would prefer to stay around LA.
Sent from my iPhone
On Aug 5, 2010, at 2:54 PM, Andrew Evans <evans.d.andrew at gmail.com> wrote:
> Hello I am trying to use the up down left right arrow keys to move an object
>
> How ever it does not seem to work and I receive no error messages any ideas?
>
> from System.Windows.Input import KeyEventHandler
>
> velocity = 10
>
> class Gui():
> def __init__(self):
> KeyEventHandler(self.KeyDown_Control)
> ................................
>
>
> def KeyDown_Control(self, s, e):
> if e.Key == Key.Right:
> self.canvas.SetLeft(self.ship, self.canvas.GetLeft(self.ship) + velocity)
> elif e.Key == Key.Left:
> self.canvas.SetLeft(self.ship, self.canvas.GetLeft(self.ship) - velocity)
> elif e.Key == Key.Up:
> self.canvas.SetTop(self.ship, self.canvas.GetTop(self.ship) - velocity)
> elif e.Key == Key.Down:
> self.canvas.SetTop(self.ship, self.canvas.GetTop(self.ship) + velocity)
>
> Cheers
>
> and thank you
>
> Andrew
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
More information about the Ironpython-users
mailing list