CLEO Help key_up <key> opcode question

CLEO related
Status
Not open for further replies.

mrsaxobit

Member
Joined
Feb 5, 2014
Messages
23
Reaction score
0
Hey.. i know of pressed_key and key_down to detect when a certain key is pressed,
but i need to detect when a certain key is lifted up, something like 

....random code in loop
wait 0
if
key_down <keycode number>
then
0ACD: show_text_highpriority "You are pressing the key" time 1000
wait 1000 
end

if
key_up <keycode number>
then
0ACD: show_text_highpriority "You stopped pressing the key" time 1000 
end

...jump to looop


I'd like to know the key_up opcode..
 

4changesLeft

Well-known member
Joined
Apr 10, 2015
Messages
365
Reaction score
3
I think you can't possibly detect that, but it's really not necessary.. Depends on what you want to do
But, you could simply do
if key_down
then
<do something>
end
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
There's no opcode for that, you can call key_down and if the result is false that means the key is not pressed.
Something like this should work too.

[shcode=cpp]
if key_down XX
then
    repeat 
        wait 0
        print "you are pressing key" 10
    until not key_down XX
    print "you stopped pressing the key" 1000
end
[/shcode]
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
or use bool if you don't want to stop the script like:

if key_down
then
1@ = true
end

if and
key_up
1@ == true
then
1@ = false
//do something
end
 

MrChristmas

Expert
Joined
Jul 29, 2014
Messages
563
Reaction score
26
This should work too If I'm not mistaking

[shcode=cpp]
wait 0
if
key_down x
then
print "Key x has been pressed" 15
else if
not key_down x
print "Please press the x key" 15
end
[/shcode]
 

4changesLeft

Well-known member
Joined
Apr 10, 2015
Messages
365
Reaction score
3
Mr.Christmas said:
This should work too If I'm not mistaking

[shcode=cpp]
wait 0
if
key_down x
then
print "Key x has been pressed" 15
else if
not key_down x
print "Please press the x key" 15
end
[/shcode]

This will always show the second text cuz you are telling it to show it if you are not pressing the key in general
 

MrChristmas

Expert
Joined
Jul 29, 2014
Messages
563
Reaction score
26
TehArgis said:
Mr.Christmas said:
This should work too If I'm not mistaking

[shcode=cpp]
wait 0
if
key_down x
then
print "Key x has been pressed" 15
else if
not key_down x
print "Please press the x key" 15
end
[/shcode]

This will always show the second text cuz you are telling it to show it if you are not pressing the key in general

I know, but that's one of the way to use this opcode :)
 
Status
Not open for further replies.
Top