You have to proxy the events and send them to the next level. Put this on the main script (like on the root node of the scene) assuming your viewport variable is called viewport (just edit that if you have a different variable name).
func _input(event):
if viewport and is_inside_tree():
viewport.input(event)
func _unhandled_input(event):
if viewport and is_inside_tree():
viewport.unhandled_input(event)
func _gui_input(event):
if viewport and is_inside_tree():
viewport._gui_input(event)