Suitie
9 years agoVisitor
left and right always fired twice!!
First of all, I am a very beginner in Roku development, so I am sorry if my question is silly... I've followed all tutorials available and now I am trying to create a little app just to learn... but i get an "error" in the simplest function, and I am frustrated
My code:
'''
sub init()
m.top.setFocus(true)
End sub
function onKeyEvent(key as String, press as Boolean) as Boolean
if (key = "left") then
print "pressing left"
return true
end if
if (key = "right") then
print "pressing right"
return true
end if
return false
end function
'''
What I get when I press "left":
pressing left
pressing left
OnKeyEvent is fired twice whenever I press a key, the first one when the key is down, and the second one when it is up. Why is this happening? Where is the mistake?
My code:
'''
sub init()
m.top.setFocus(true)
End sub
function onKeyEvent(key as String, press as Boolean) as Boolean
if (key = "left") then
print "pressing left"
return true
end if
if (key = "right") then
print "pressing right"
return true
end if
return false
end function
'''
What I get when I press "left":
pressing left
pressing left
OnKeyEvent is fired twice whenever I press a key, the first one when the key is down, and the second one when it is up. Why is this happening? Where is the mistake?