Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMartin Droshow
6,891 PointsUse arrow keys for movement fo dungeon game instead of writing RIGHT, DOWN, LEFT
Hi There,
I am sick of writing right, down, left for the dungeon game. Want to make the movement based on using arrow keys. I thought that it would be a piece of cake, but after googling some pages in seems pretty intimidating, not like Java's scanner library.
There is some getch () method and stuff, it looks intimidating. I need some guidance how tomake this based on user's input of arrow keys, not writing annoying left, right, down stuff.
I think this would be useful for others as well
Thanks Martin
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsUnfortunately, it is not possible to rely solely on arrow keys for movement from the command line interface. The command window or shell interface intercepts the arrow keystroke and does not pass it on to the program. A return
key is required to send characters to the program.
To solely use arrow keys, a GUI or other user interface scheme would need to be created to interpret keystrokes directly without using a command shell. tkinter or other GUI would be a good place to start.