Skip to content

Instantly share code, notes, and snippets.

@pvn
Created January 1, 2023 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pvn/9a461b568e87ac5a86a3c03985e4857a to your computer and use it in GitHub Desktop.
Save pvn/9a461b568e87ac5a86a3c03985e4857a to your computer and use it in GitHub Desktop.
tvOS: Detecting Button Presses
override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
guard let buttonPress = presses.first?.type else { return }
switch(buttonPress) {
case .menu:
print("Menu")
case .playPause:
print("Play/Pause")
case .select:
print("select")
case .upArrow:
print("Up arrow")
case .downArrow:
print("Down arrow")
case .leftArrow:
print("Left arrow")
case .rightArrow:
print("right arrow")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment