How to use keyboard shortcut navigation with a table in Bubble
In this Bubble.io tutorial we demonstrate how to nagivate up and down a table using the up and down arrows on a keyboard. This Bubble tutorial shows how to use custom states to track the selected row of a repeating group and change this selection with the arrow keys. The plugin used is Air Keyboard Shortcut by Zeroqode.
Unlock keyboard navigation: Learn how to add arrow key controls and actions to your repeating groups in Bubble.
Master custom states: Discover how to use custom states to create dynamic row selection in your Bubble app's tables.
Take your Bubble app to the next level with professional keyboard shortcuts - just like Gmail and other top SaaS apps!
Adding Keyboard Navigation to a Table in Bubble
In a previous video, I showed how to use the plugin Air Keyboard Shortcut to add a nice pop-over search box to search through my contacts. But what if I wanted to just use my arrow keys to go up and down? So if I hit the down key, it goes to Tony Stark, then hit down again it goes to Peggy Carter, and so on, and then have an action to enact on the row in my repeating group that is selected. Let's set that up.
Setting Up the Repeating Group
Here is my Bubble editor and I'm going to begin by looking in my repeating group. I've already got all of my elements contained in a group, and I'm going to use that to style the row whether it is selected or not selected. This is a prime example of where an option set will come in useful.
Creating an Option Set
I will just put an option set up here. I'm just going to change this to "list of users" so that it's more clear. Let's create an option set and I'll say "selected row" and it's going to be a number. The default will be zero.
Styling the Selected Row
Then I can go into my group here, so the first child of my repeating group, and I can go condition when "list of users selected row" is current cell's index. This refers to this index. You just have to work out on the platform you're using because in web development some indexes start with zero, Bubble starts with one. So this is row one, row two, row three, and so on.
Adding Background Color
When the custom state's row is current cell's index, I'm going to change the background. You see it doesn't give me background color; that's because I haven't set a background color. So I'm going to set a background color here of default white. Now if I go back to the conditional here, I can set color and I'll just change it to a light gray. That makes a nice difference.
Setting Up Keyboard Shortcuts
I want to enact an action if my user hits the down key. In my plugins, I've got Air Keyboard Shortcut. I need to add an element of Air Keyboard Shortcut for every key that could possibly be pressed that I want to enact a workflow on.
Creating Workflows for Arrow Keys
I'm gonna call this one "down" and then in my workflows, I'm gonna say when Air Keyboard Shortcut is triggered. I have to choose one; my shortcut A is for my search box popover, so I need to make this one B. I want to add one to my custom state. Set state of "list of users selected row" and then with custom states, unlike when I'm modifying a value in a database, I have to refer to itself and then the action. So I can get "list of users selected row" plus one.
Adding Up Arrow Functionality
Let's copy and paste that. Now I have C, and C is going to be up. I can duplicate this. When C is clicked, I'm gonna say minus one.
Testing the Navigation
Let's test this. No row is selected if I press down. You see it goes down. Now you also notice that the window moves. That's because when you're running with the debugger, Bubble includes this view that's like 60-70 extra pixels on the bottom. If I get rid of the debugger, you can see that as long as my page is not too big and too high, then it works perfectly.
Adding Enter Key Functionality
Let's say I went down to Natasha Romanoff and I wanted to hit a key combination or maybe enter to view her profile. We need to have another instance, this time it's D, and I'm going to try enter. The reason I'm a little bit apprehensive about enter is that in some instances you're competing with what the browser thinks is the default action. Obviously, a key combination, or something like enter, is quite commonly used in forms, etc.
Creating a Navigate Workflow
I'm going to try enter, and so this time when shortcut D is selected, I'm going to go for a navigate go to page. Let me just check I have got a contact page setup here. My page here is of type contact and all the entries in my database here are also of type contact. That then means that I can on D go to page destination contacts.
Sending Data to the Contact Page
I have to send some data. Now how do I retrieve that data? Because all I'm doing at the moment is just storing in a custom state a number value. I can refer to the repeating group. I've got a couple of repeating groups there, just go that one master because that's the one I'm using. I can go repeating group master list of contacts item number, and now I can refer to my "list of users selected row" because that's the number.
Testing the Navigation
Let's test it. Go down to Natasha Romanoff, hit enter, and Bubble enacts a workflow and takes me across. Just so that stands out even more clearly, I haven't got my database fields here set up. This is type contact of page contact, and so then I can add the name and last name fields. Let's test it with one other. This list of my users, we'll go to preview and let's go down to Bruce Banner, hit enter, and there we go, we're taken through to Bruce Banner.
Conclusion
There we have it. That is quite a cool way of using keyboard shortcuts in your app. I think it's certainly something that you can do that will up the professionalism of your app. If you think of like the huge services that people use like Gmail and other business applications, there are so many keyboard shortcuts going on. It would be a good way to set your Bubble app aside from the rest and make it even more professional by adding in keyboard shortcuts and keyboard navigation as it's becoming increasingly popular with SaaS apps.
Get the Complete Bundle for Just $350 $99
Access 3 courses, 400+ tutorials, and a vibrant community to support every step of your app-building journey.
Start building with total confidence
No more delays. With 30+ hours of expert content, you’ll have the insights needed to build effectively.
Find every solution in one place
No more searching across platforms for tutorials. Our bundle has everything you need, with 400+ videos covering every feature and technique.
Dive deep into every detail
Get beyond the basics with comprehensive, in-depth courses & no code tutorials that empower you to create a feature-rich, professional app.
Save over 70%!
Valued at $80
Valued at $85
Valued at $30
Valued at $110
Valued at $45
Can't find what you're looking for?
Search our 300+ Bubble tutorial videos. Start learning no code today!
Have questions?
We have answers!
Find answers to common questions about our membership plans, programs, and more.
We're here to help you launch your no code SaaS. Reach out to the team and we'll double check our vast library for useful content. We'll advise you on how we'd tackle the same problem and there's a good chance we'll record the video to help the wider community.
As a Planet No Code member, you'll receive a discount on our Bubble coaching sessions. Monthly members receive a 10% discount, while Annual members receive a 17.5% discount. To redeem your discount, simply log into your account and book a coaching session through our platform.
Our 8-week intensive mentorship program is designed to provide personalized guidance and support to help you accelerate your startup journey. You'll be matched with a startup expert who will work with you one-on-one to set goals, overcome challenges, and make rapid progress.
To apply for the Mastery Program, simply click the "Request Invitation" button on our pricing page and fill out the application form. Our team will review your application and schedule a call with you to discuss your goals and determine if the program is a good fit for your needs.
We accept all major credit cards, including Visa, Mastercard, American Express, and Discover.
While we don't offer a free trial, we do provide a 14-day money-back guarantee. If you're not completely satisfied with your membership within the first 14 days, simply contact our support team, and we'll issue a full refund.