This post is the first in a series of three on UIKeyCommands on iOS. In this first post, we’ll go over
UIKeyCommand at a high level.
UIKeyCommands represent a key press (or combination of key presses) on a hardware keyboard that will trigger an action. In short, you can think of these as keyboard shortcuts. The system already has a few built-in keyboard shortcuts. Some of these are keyboard shortcuts are Cut (⌘ + x), Copy (⌘ + c), and Paste (⌘ + v).
Beginning in iOS 7, Apple started allowing developers to implement keyboard shortcuts. The system already handles Cut, Copy and Paste and developers won’t need to implement these.
These keyboard shortcuts have been around for a few years. So, it’s easy to see how other developers have implemented these. A great way to discover what keyboard shortcuts apps have is to launch the app, and then hold down the command (⌘) key. Here’s an example from my app Beer Style Guidelines.
There are two parts to implement UIKeyCommands in your app. First, is the
UIKeyCommand object itself. Then these UIKeyCommands need to be integrated into the app.
The initializer for UIKeyCommand has a lot going on. You don’t need to use every parameter. Here are the minimum parameters to create a UIKeyCommand object. Those parameters are:
title: This is the display title of the keyboard shortcut.
action: This parameter points to the method that gets called from this shortcut.
input: This is the keyboard key (a string) that is part of the keyboard shortcut. For example, the “c” in the Copy shortcut (⌘ + c)
modifierFlags: This is the modifying key that is the other part of the keyboard shortcut. For example, the “⌘” in the Copy shortcut (⌘ + c)
Putting all of this together, you can create a keyboard shortcut like this:
let infoCommand = UIKeyCommand(title: "Show Info", action: #selector(showInfo), input: "i", modifierFlags: .command)
In this example, the user will trigger a keyboard shortcut to show info when they use ⌘ + i. This will show them an iOS alert with a simple message in it.
I’ve created a sample app that pulls all the various pieces together. The sample app, is simple. It has a single keyboard shortcut. You can discover this just like keyboard shortcuts in other iOS apps.
Download and run the sample app. Once launched, hold down on the Command key (⌘) until you see the prompt showing the single keyboard shortcut within the app.
If nothing shows up, and you’re testing this in the simulator, you may need to enable “Send Keyboard Input to Device” in the simulator. This can be done through the menu system by selecting I/O → Input → Send Keyboard Input to Device. Or, you can click on this button in the toolbar (below) of the simulator. Without doing this, sometimes the keyboard shortcuts can be lost, and it will seem like the keyboard shortcuts are not working.
That’s it. Keyboard shortcuts are straightforward to set up and get working in your apps. Next time we’ll get a little more in-depth on UIKeyCommand.
It’s been a busy month. I’m not even sure where the month went. I figured I’d post a general update on what I’ve been up to.
I’ve been super busy at work, working on a new (to us) property. I’m not sure if I can announce what that property is yet, so I won’t. Once it launches, I’ll probably post an update here with more info.
As far as personal projects go, I’ve shipped a large update to Beer Style Guidelines. This update includes the Brewers Association 2021 Beer Style Guidelines. The release notes are here. I love updating the app with new guides as they come out, but I always forget how much work it is. I do a fair bit of testing the guide out before I release it, but I just know that I’m going go missing something.
This last few weeks, I’ve been really busy working on a few server components to another update to Beer Style Guidelines. It’s not ready yet and users shouldn’t notice any difference in how the app works. But this new set of server components it building towards some future features.
I haven’t been playing many video games this month. I’ve been so busy with the development updates above, it doesn’t leave a lot of time for playing video games at night.
I’ve dabbled in a few new games, but nothing has really hooked me. I think if a game hooked me, I’d find a way to play the game more.
Some of the games I’ve started:
I probably spent the most time playing LEGO Harry Potter Collection. I love LEGO games, they aren’t usually hard, and I can let my mind wander a bit while playing through them.
I stared Gears of War, but didn’t make it too far in. I’ve played through this game a few times, years ago. I have a lot of fond memories playing through these with my brother. But I just couldn’t really get into it again.
I finished the Pikmin 3 demo, but not sure I’m ready for the full game yet. I love the early game of Pikmin games, but I always get to a point where I get frustrated with the games. It’s probably because I’m bad at video games. I’m still debating whether I want to get this game or not.
I tried Hollow Knight. I’ve heard so many good things about it. It made me realize (even more) that I’m bad at video games. I couldn’t even get past the first boss (False Knight) before getting frustrated and giving up. I feel like I should keep at it, but I am just so bad at this game.
I’ve read a handful of books this month. Looking back at the list, it was more than I expected. I listen to most of my books. It makes it much easier to enjoy books while I go for walks, runs, or while driving in the car.
In March, I finished these books:
Bossypants was a fun, quick read. I like Tina Fey and the work she’s done. This book was written during her time working on 30 Rock (which was a great show). Tina is also an Eagles fan, so that helps immensely.
I am a big fan of the new Star Wars: The High Republic content that’s been coming out this year. It’s an entirely new era being discovered in Star Wars. I’ve been keeping up with the novels and comic books in this ear and have really been enjoying them. I listened to about half of this book in a single day during a long road trip.
I really enjoyed the art style in Star Wars: The Rise of Skywalker Graphic Novel Adaptation. The graphic novel adaptation gets the bulk of the story across from the movie and the (non-graphic) novel adaptation. I still enjoying reading comics on my iPad. Although, I only really list the graphic novels or omnibuses on my list of books I’ve read.
The Lead Developer book was an impulse read of mine. I saw it promoted by some iOS developers I follow on Twitter, so I decided to buy it. The book is a good first version. There were a handful of typos throughout the book, but I could easily see past those. But the book does give a good overview of what a lead developer’s responsibilities are and some practical tips on how to survive as one. This is a relatively short book that I read in 3 or 4 sittings.
This has been quite a busy month. I didn’t even cover the movies and TV shows that we’ve been watching. Maybe I’ll cover that in a different post, maybe not.
I hope to provide more frequent updates on the site. But I’m not always great with that.
There isn’t a lot to the plot. If you’ve played any other Super Mario games, this one has a very similar plot. Princess Peach was kidnapped by Bowser and it’s up to you to rescue her. It’s not very imaginative. But playing the game is a lot of fun.
Once you’ve finished the game, you can go back to all of the worlds and attempt to collect Power Moons. I did not collect every Power Moon in the game. I’m not sure if I’ll even go back and play through more. I had just enough fun playing through the main storyline. It was the perfect amount for me.
It was a very fun game. It also wasn’t too difficult to get through the main storyline. I’d recommend this for anyone who enjoys 3D Super Mario games.
Over the past week, I’ve made a handful of changes to the site. It’s been a long time since I’ve made any appreciable updates to the site. I’ve moved to a new host, implemented dark mode and added category support. I consider them quality of life updates. None of these changes are groundbreaking, but these are things I’ve wanted to do on the site for a while now.
Previously, I was using GitHub Pages to host the site. But I wanted a bit more control over things. This week, I moved to Netlify. Netlify has the same ease of use that GitHub Pages provides, but I get a bit more insight into what’s happening during site deployments.
I’ve also implemented dark mode support on the site. I’ve been using a Jekyll theme called Lanyon for a few years now. The theme has been great, but it doesn’t support dark mode out of the box. Adding it wasn’t too bad, but I’ve probably done it in the most inefficient way possible and missed a handful of elements.
The lack of categories is something that’s been bugging me for a long time. I’ve finally added support for them. Well, kind of. Jekyll (the software that runs this site) already supports categories, but the Lanyon theme doesn’t (out of the box). Adding support for categories was easy enough. Each post will show the categories for that post (see the image above). I’ve also created a categories page. So you can browse posts by categories.
I’ve been thinking about a complete redesign for the site. I’m not sure if I want a new Jekyll theme, or if I want to roll my own design for the site. A new Jekyll theme would be an easy way to get a new look. The themes I’ve seen out there aren’t quite what I want. I’m not sure I have the time (or energy) to roll my own new theme/look for the site.
Please enjoy the new features of the site.
I recently finished playing through Star Wars Jedi: Fallen Order. What a good game.
I really enjoyed the game quite a bit. I bought the game when it first came out but kept getting distracted from it. This was my third attempt at the game. I finally finished it.
I played through the game on “Story Mode” which is the easiest difficulty. I used to play games on the hardest difficulty, but in the last few years, I just want to experience the story and not struggle with gameplay.
This game takes place a few years after Star Wars: Episode III – Revenge of the Sith . I won’t give away any spoilers here. But it was neat to explore a whole new storyline in the Star Wars universe. This game has a new set of (main) characters. Along with some villains that were introduced in Star Wars Rebels (an amazing TV show).
There’s this great Uncharted vibe to this game. You get to explore and solve puzzles in a variety of environments. I loved the Uncharted games, and this game feels similar. The story is also good, but I’m not sure if it’s because of the game’s story or because I really enjoy the Star Wars universe.
I would recommend this game to anyone who likes Star Wars and environmental puzzle games. But who am I kidding? If they are into those types of games, they’ve probably already played Star Wars Jedi: Fallen Order.
I’m not entire sure what I’m going to play through next. I’ve dabbled in a few games, but nothing has really grabbed me yet.