
-----------------------------------
That Asian Guy
Tue Nov 27, 2007 7:42 pm

Help with Input.KeyDown not detecting held keys
-----------------------------------
how do i get Turing to not detect held keys
For example:



var key : array char of boolean
var pressed1, pressed2 : boolean

loop

Input.KeyDown (key)

% draw 3 boxes
drawfillbox (100, 100, 110, 110, blue)
drawfillbox (110, 100, 120, 110, red)
drawfillbox (120, 100, 130, 110, blue)

% wipe out boxes as left arrow is pressed
if key (KEY_LEFT_ARROW)  and pressed1 = false then
drawfillbox (100, 100, 110, 110, white)
pressed1 := true
elsif key (KEY_LEFT_ARROW) and pressed1 = true and pressed2= false then
drawfillbox (110, 100, 120, 110, white)
pressed2 := true
end if
end loop


holding down left will make both boxes disappear

how do i change it so tht they will disappear at each press?

-----------------------------------
Zampano
Tue Nov 27, 2007 8:23 pm

Re: Help with Input.KeyDown not detecting held keys
-----------------------------------
The loop passes far too quickly to make a difference to a human viewer. Try putting a delay if a button is pressed.

-----------------------------------
Saad
Tue Nov 27, 2007 8:23 pm

RE:Help with Input.KeyDown not detecting held keys
-----------------------------------
Its still not the error, the error is that you should set it to false when the key isn't pressed

-----------------------------------
That Asian Guy
Tue Nov 27, 2007 8:31 pm

RE:Help with Input.KeyDown not detecting held keys
-----------------------------------
oops its supposed to be set to false, ignore that

what im trying to get to is how do i enter code so that the two boxes will be wiped after the left arrow key is pressed twice

right now, holding down the left arrow will wipe out both (btw i dont know why i drew 3 boxes, ignore that too)

-----------------------------------
Saad
Tue Nov 27, 2007 8:49 pm

RE:Help with Input.KeyDown not detecting held keys
-----------------------------------
There is an error in your code in which you don't give the variables an initial value but after fixing it. 

Although I still don't see the boxes getting wiped out after setting them both to false

-----------------------------------
Jestar
Tue Nov 27, 2007 8:59 pm

Re: Help with Input.KeyDown not detecting held keys
-----------------------------------
I think this is what you mean....if not, my bad :D



var pressed : int := 1
var k : string (1)


% draw 3 boxes
drawfillbox (100, 100, 110, 110, blue)
drawfillbox (110, 100, 120, 110, red)
drawfillbox (120, 100, 130, 110, blue)

loop
    if hasch then
        getch (k)
        % wipe out boxes as left arrow is pressed
        if k = KEY_LEFT_ARROW and pressed = 1 then
            drawfillbox (100, 100, 110, 110, white)
            pressed := pressed + 1
        elsif k = KEY_LEFT_ARROW and pressed = 2 then
            drawfillbox (110, 100, 120, 110, white)
            pressed := pressed - 1
        end if
        delay (1)
    end if
end loop


-----------------------------------
That Asian Guy
Sun Dec 02, 2007 4:18 pm

RE:Help with Input.KeyDown not detecting held keys
-----------------------------------
hasch...

thanks thats the command i needed
