Computer Science Canada

How to detect if a key is being held down?

Author:  CheshireFox [ 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.

Author:  Raknarg [ 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

Author:  CheshireFox [ 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

Author:  Tony [ 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.

Author:  Raknarg [ 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.

Author:  CheshireFox [ 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.

Author:  Raknarg [ 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?


: