

Let’s say one day we add an input field to our application allowing users to search layers. This is very simple, you can just dump the contents of registeredShortcuts. DevTools.įor your internal debugging tools, you might want to see which shortcuts are currently registered if something goes wrong.
FIFA WEB APP HACK CODE
If you support older browsers, you would need to ensure you transpile your code and use older browser APIs for event detection. This guide uses a modern set of JavaScript features. However, as of March 2018, there is no reliable API to detect a presence of a keyboard. You might not want to serve this code to your mobile users without keyboard. The second point would be figuring out whether we need to ship this functionality at all? After all, these are called keyboard shortcuts for a reason. This variable could then get minified during our build process to shave some bits off the final package. Instead of using multiple string literals with the same value, we could replace them with a single variable. I used a few shortcuts (pun intended) in this article to keep it simple. That is, unless you intend to quit tomorrow and let your successors deal with this code one beautiful day when it breaks. The marketing team can start promoting the 💩 out of this new, shiny feature.īut as an engineering team, our work is not over yet. Are we ready to compete with our nemesis now? Totally. Works like a charm, right? We have successfully added a support for keyboard shortcuts to our app. That’s handy, since we will want to ensure our shortcuts work only in the editor. They have not made a design hire yet and there are only 2 tools to choose from - Brush and Select. (Hopefully, Abode won’t sue us for leaking their product.)Īs you can see, I obtained an early version of their system. I managed to get ahold of the Abode PhotoStore application and published it to CodePen so you can get started quickly and follow along. But you should be able to read ES6, because I am not about that verbose code life. We will be focusing on the concepts, not a particular implementation. In React, these methods are called componentDidMount() and componentWillUnmount().ĭon’t panic if you use a vanilla JavaScript, you can still follow along. What we need are the onCreate() and onDestroy() lifecycle methods, so if your framework offers an equivalent, this guide will be easy to follow. However, if you are adding shortcuts to your application, chances are, you already use some SPA framework. I put only in quotes because setting up React can be daunting if you never worked with it before. What do we need to deliver this delightful experience? For this article, I will use “only” React with JSX, allowing me to write compact code. And you do care about that, correct? That’s what I thought. In those cases, I would even count them as a part of the overall accessibility strategy. Sometimes, your users cannot or do not want to use their mouse, making shortcuts almost a necessary part of your product. Offering keyboard shortcuts to the most used features makes your users faster, more productive, and as a result, happier. While that might be true, users of every application develop habits and adopt certain workflows. ”This does not apply to me, I am not working on a photo editing application,” you think. We can prevent a lot of pain down the road by designing our solution in a way that supports this theoretical functionality, even if we decide not to implement it at this time.

After all, this should not delay our launch. One day, your product manager announces that since your competitor has keyboard shortcuts, you need them too to make switching easier for their existing users. It sounds like an image storing service, but it is not! In fact, this is a web-based alternative to a popular desktop application. You work for a large corporation called Adob… you work at a startup called Abode developing a photo editing application called PhotoStore. React and a few lines of code to the rescue!
