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

Username:   Password: 
 RegisterRegister   
 How to detect if a key is being held down?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
CheshireFox




PostPosted: Tue May 20, 2014 9:52 am   Post subject: How to detect if a key is being held down?

Just wondering if there is a way to detect if a key is being held down, preferbaly without delays.
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: Tue May 20, 2014 11:51 am   Post subject: RE:How to detect if a key is being held down?

http://compsci.ca/v3/viewtopic.php?t=114
CheshireFox




PostPosted: Tue May 20, 2014 4:20 pm   Post subject: Re: How to detect if a key is being held down?

Yes I've read the tutorial, but I want to know if there is a way to detect if a key is being HELD down because I want part of my program to run only once until the user presses the corressponding key again
Tony




PostPosted: Tue May 20, 2014 5:51 pm   Post subject: Re: How to detect if a key is being held down?

CheshireFox @ Tue May 20, 2014 4:20 pm wrote:
if a key is being HELD down

What does it mean for a key to be "held down"? There's some area of ambiguity -- was that a really fast hold, or a really slow click? Once you define what it means to be held (likely along the lines of "state DOWN and state DOWN some time later"), you can use examples from the tutorial to implement your definition.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Raknarg




PostPosted: Tue May 20, 2014 9:23 pm   Post subject: RE:How to detect if a key is being held down?

Turing:

var key : array char of boolean

loop
    Input.KeyDown (key)
    put key (KEY_UP_ARROW)
end loop


Notice how when the up arrow key is pressed it says true, and when it is not pressed it says false.
CheshireFox




PostPosted: Thu May 22, 2014 9:42 am   Post subject: Re: How to detect if a key is being held down?

I want to know how to have a piece of code run if a user presses a key but have that piece of code only run when the user lets go of the key and presses it again.
Raknarg




PostPosted: Thu May 22, 2014 11:18 am   Post subject: RE:How to detect if a key is being held down?

Ok, well like Tony said, define what you mean by the double click. Do you mean like two presses in quick succession, or every second time a button is clicked?
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  [ 7 Posts ]
Jump to:   


Style:  
Search: