---
title: "#210: Adding Keyboard Navigation to UIKit with KBKit ⌨️"
url: https://littlebitesofcocoa.com/210-adding-keyboard-navigation-to-uikit-with-kbkit
author: Jake Marsh
date: 2016-03-11
published: 2016-03-11
topics: ["Libraries","UIKit"]
description: "Today we'll look at an interesting library from Evan Dekhayser called KBKit. It extends UIKit to add support for navigating around using a physical keyboard."
---

# #210: Adding Keyboard Navigation to UIKit with KBKit ⌨️

By Jake Marsh, March 11, 2016. HTML: https://littlebitesofcocoa.com/210-adding-keyboard-navigation-to-uikit-with-kbkit

Today we'll look at an interesting library from [Evan Dekhayser](https://github.com/edekhayser) called [KBKit](https://github.com/edekhayser/KBKit). It extends UIKit to add support for navigating around using a physical keyboard. (Think either bluetooth or other keyboard connected to an iPad, but would also work on iPhone.) Let's take a look.

[KBKit](https://github.com/edekhayser/KBKit) consists of a few subclasses of common UIKit classes. _KBTableView_ adds **Up Arrow**, **Down Arrow**, and **Return Key** functionality to **UITableView**. Very cool.

``` swift
let tableView = KBTableView(frame: CGRect.zero, style: .Plain)

tableView.onSelection = { (indexPath: NSIndexPath) in
  // called when user pressed 'Return' or 'Command + D'
}

tableView.onFocus = { (current: NSIndexPath?, previous: NSIndexPath?) in
  // called as user navigates with arrow keys
}
```

We can use _KBNavigationController_ to gain a **Command + Left Arrow** shortcut for going "back" (i.e. popping to the previous **view controller** in the stack).

Last but not least, _KBTabBarController_ adds support for pressing **Command + 1**, **Command + 2**, **Command + 3**, etc. to change the currently selected tab. It supports up to 5 tabs. Neat!

More info about _KBKit_ can be found at [git.io/kbkit](http://git.io/kbkit)
