Your question is very generic and so I can only give an example as a generalization.
function onKeyEvent(key as String, press as Boolean) as Boolean
if press then
if key = "play"
if (m.video.state = "playing")
m.video.control = "pause"
else if (m.video.state = "paused")
m.video.control = "resume"
return true
end if
end if
end if
end if
return false
end function