- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Onkey event in Roku for back button funtionality
I am working with Scenegraph Developer Extension (SGDEX) for developing one login flow.
Now when I press Ok button in textBox the keyboard is appearing ,
But what I want is when I press backButton (once) the keyboard should disapper and if I press backButton again my screen should navigate to previous screen,
Note:- I want keyboard to get closed using back button only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Onkey event in Roku for back button funtionality
You've posted to a forum for Roku users, where few, if any, will be able to help. The Developers forums are here: https://community.roku.com/t5/Developers/ct-p/channel-developers
I am not a Roku employee, only a user like you. Please, no support questions via private message -- post them publicly to the Community where others may benefit as well.
If this post solves your problem please help others find this answer by clicking "Accept as Solution.".
Ultra 4850 | Ultra 4800 | Streaming Stick 4K+ 3821 | TCL Roku TV 43S245/C107X

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Onkey event in Roku for back button funtionality
function onKeyEvent(key as string, press as boolean) as boolean
handled = false
if press then
if(key = "back")
if (m.keyboard.visible)
m.keyboard.visible = false
' only return true when you want to swallow the keypress
' we want to swallow the keypress only when keyboard is visible and back is pressed
handled = true
end if
end if
end if
return handled
end function
... or even shorter version ...
function onKeyEvent(key as string, press as boolean) as boolean
handled = false
if press and (key = "back") and (m.keyboard.visible)
m.keyboard.visible = false
' only return true when you want to swallow the keypress
' we want to swallow the keypress only when keyboard is visible and back is pressed
handled = true
end if
return handled
end function
You almost had it. You just forgot to only swallow the keypress at the right time part. You don't want to return true every time the back button is pressed which is what your code block did. You only want to swallow the keypress (aka return true) when you have a visible keyboard.
When the OnKeyEvent returns false it allows the keypress to pass upwards to the other components in the extend/scene.