View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vídeos

Abrir menu Fechar menu
  • Coleções
  • Todos os vídeos
  • Sobre

Mais vídeos

  • Sobre
  • Código
  • Support hardware keyboards in your app

    When people use hardware keyboards with your app, they're not only getting a more tactile and familiar typing experience — they can quickly navigate or use keyboard shortcuts, too. Discover how you can best support hardware keyboards for your iPadOS and Mac Catalyst apps: We'll demystify the responder chain and show you best practices for implementing custom keyboard shortcuts. Learn how easy it is to get up and running with common system keyboard shortcuts, use modifier flags with gesture recognizers, and leverage the raw keyboard event API to respond to key down and key up events.

    Recursos

    • Adding hardware keyboard support to your app
    • UIResponderStandardEditActions
      • Vídeo HD
      • Vídeo SD

    Vídeos relacionados

    WWDC22

    • Bring your iOS app to the Mac

    WWDC21

    • Take your iPad apps to the next level

    WWDC20

    • Bring keyboard and mouse gaming to iPad
    • Handle trackpad and mouse input
    • Meet Scribble for iPad
    • What's new in Mac Catalyst

    WWDC19

    • Modernizing Your UI for iOS 13
    • Taking iPad Apps for Mac to the Next Level
  • Buscar neste vídeo...
    • 0:01 - PlayerViewController

      class PlayerViewController: UIViewController {
      
          override var canBecomeFirstResponder: Bool {
              return true 
          }
      
          override func viewDidAppear(_ animated: Bool) {
              becomeFirstResponder()
          }
      
          override var keyCommands: [UIKeyCommand]? {
              return [
                  UIKeyCommand(title: NSLocalizedString("PLAY_PAUSE", comment: "…"),
                              action: #selector(playPause),
                               input: " ")
              ]
          }
      }
    • 0:02 - SongListTableViewController

      class SongListTableViewController: UITableViewController {
      
          override var canBecomeFirstResponder: Bool {
              return true
          }
          
          override func viewDidAppear(_ animated: Bool) {
              becomeFirstResponder()
          }
          
          /* UIResponderStandardEditActions */
      
          override func selectAll(_ sender: Any?) { … }
      
          override func copy(_ sender: Any?) { … }
      
          override func paste(_ sender: Any?) { … }
      
      }
    • 0:03 - UIKeyCommand

      class UIKeyCommand : UICommand {
          ...
      }
      
      override func buildMenu(with builder: UIMenuBuilder) {
          builder.replaceChildren(ofMenu: .file) { children in
              return [ UIKeyCommand() ] + children
          }
      }
    • 0:04 - Extending selection with keyboard

      optional func tableView(_ tableView: UITableView,
             shouldBeginMultipleSelectionInteractionAt indexPath: IndexPath) -> Bool
      
      optional func tableView(_ tableView: UITableView,
             didBeginMultipleSelectionInteractionAt indexPath: IndexPath)
    • 0:05 - recognizedDragGesture

      func recognizedDragGesture(_ panGesture: UIPanGestureRecognizer) {
      
          if panGesture.modifierFlags.contains(.command) {
              snapToGrid = true
          } else if panGesture.modifierFlags.contains(.shift) {
              constrainAspectRatio = true
          }
          
          ...
      }
    • 0:06 - Responding to raw keyboard events

      class UIResponder: NSObject {
          func pressesBegan(_ presses: Set<UIPress>,
                           with event: UIPressesEvent)
          
          func pressesEnded(_ presses: Set<UIPress>,
                           with event: UIPressesEvent)
      }
    • 0:07 - CanvasViewController

      class CanvasViewController: UIViewController {
           
           override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
               for press in presses {
                   guard let key = press.key else { continue }
                   switch key.keyCode {
                   case .keyboardUpArrow: startMoveUp()
                   case .keyboardDownArrow: startMoveDown()
                       …
                   }
           }
           }
      
           override func pressesEnded(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
               stopMoving()
           }
      
      }
    • 0:08 - CanvasViewController modifier flags

      class CanvasViewController: UIViewController {
      
          override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
              var selectWhileMoving = false
              for press in presses {
                  guard let key = press.key else { continue }
                  if key.modifierFlags.contains(.shift) {
                      selectWhileMoving = true
                  }
                      
                  switch key.keyCode {
                  case .keyboardUpArrow: startMoveUp()
                          
                  }
              }
          }
      }

Developer Footer

  • Vídeos
  • WWDC20
  • Support hardware keyboards in your app
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines