Skip to content

android hardware back button does not work in kivy #1903

Closed
@Fak3

Description

@Fak3

kivy version: git master (and latest stable)
p4a version: develop branch (and latest stable)
backend: sdl2

i have added keyboard hook for hardware button as suggested in p4a documentation:

class YourApp(App):

   def build(self):
      Window.bind(on_keyboard=self.key_input)
      return Widget() # your root widget here as normal

   def key_input(self, window, key, scancode, codepoint, modifier):
      if key == 27:
         print('back pressed')
      else:           # the key now does nothing
         return False

The hook does not receive any hardware backbutton input until i click any kivy TextInput. After i click any TextInput, android keyboard appears, then i can close it, and from now on hardware back button works just fine everywhere in the app (key 27 input is received). Another quirk: it stops working again if app is paused and resumed.
It happens only on some android devices: namely ZTE nubia z11 mini (android 5.1) and samsung galaxy S5. On some other devices it works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions