Computer Science Canada

Using a char without pressing enter

Author:  silvershadow [ Sat Jun 03, 2006 7:43 am ]
Post subject:  Using a char without pressing enter

im building a simple game, but im tired of having to type in words and pressing enter to do anything. i was hoping, to just press one single keyboard button, to make something take place.

code:

var choice : char

get choice

if choice = 'u' then
    guess := 1
    put "You bet under 7"
end if


that is not my full code, that is just a sample of it, which i shortened to help better understand my problem.

when the user has to enter their choice..they press a character, but then they have to press Enter after it in order for it to work. is it possible to edit my code so that way they wont have to press Enter? i just want the user to press the charactor and it automatically works.

thanks.

Author:  TheOneTrueGod [ Sat Jun 03, 2006 8:03 am ]
Post subject: 

code:

var ch : char %Also works with strings
ch := getchar
put ch

Author:  silvershadow [ Sat Jun 03, 2006 8:42 am ]
Post subject: 

thanks alot, really appreciate it. Smile

Author:  TheOneTrueGod [ Sat Jun 03, 2006 9:28 am ]
Post subject: 

No problem, thats what the help forum is here for Very Happy


: