Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 keyboard keys (help)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
turing91




PostPosted: Thu Jan 11, 2007 9:49 pm   Post subject: keyboard keys (help)

How would you make a simple program where if you pressed the "d" key on the keyboard it says something like "You pressed the d key"

i know you can use
code:

var key : string (1)
loop
    getch (key)
    if key = KEY_CTRL_D then
        put "You pressed the 'd' key"
    end if
end loop


but how would you do it without pressing control?
Sponsor
Sponsor
Sponsor
sponsor
Ultrahex




PostPosted: Thu Jan 11, 2007 10:45 pm   Post subject: Re: keyboard keys (help)

There is actually two ways for keyboard input... but i think you understand what you are doing so ill just show you the code(s)

code:

/*
  Same Method in Which You
  Prescribed Above Using CTRL
*/

var key : string (1)
loop
    getch (key)
    if key = 'd' then
        put "You pressed the 'd' key"
    end if
end loop



code:

/*
  This loops repeatedly, and check each loop whether
  the character 'd' is being pressed, and if so, runs code.
*/

var chars : array char of boolean
loop
    Input.KeyDown (chars)
    if chars ('d') then
        put "You pressed the 'd' key"
    end if
    delay(10)
end loop
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: