7

Clicking on column headers in a table to set the sort order (or toggle ascending/descending if already sorting by this column) is a standard UI technique.

However, it is mouse-only. Is there a standard way to do the same thing using the keyboard? If not, what would you recommend as keyboard shortcuts?

4 Answers 4

2

I don't know how standard it is yet, but the w3c wai-aria authoring practices guide has keyboard accessibility guidelines for all sorts of things, including sortable tables.

2
  • If its about a website I'd join Pam's idea of adapting the W3C standard. If its a native application it will depend on the OS. I'd only implement it if sorting is massively used. As I don't think people will know how to use it you could explain the keyboard shortcut via a mouseover infobox at the column header.
    – erikrojo
    Apr 29, 2011 at 18:12
  • Maybe you could add an abstract of what the W3C is advising?
    – stefan.s
    May 19, 2014 at 8:59
2

I also agree with Pam in that you should first consult established standards like W3. However, the W3-aria recommendation for tables is essentially an implementation of keyboard-based navigation (arrow keys + space bar). You may want something more.

It helps to understand your motivation for wishing to implement keyboard-driven sorting. If it's an accessibility issue, then W3-aria is a starting point for sure, since that's its driving force. However, it doesn't present you with a very QUICK method of access. If you have many columns in a table, it will take that many right arrow presses to get over to the column and then perform the sort. Bear in mind that if your end-user is motor-skill impaired or is vision impaired, she will have already had to perform a number of keypresses just to tab into the table.

At this point, hotkeys become more attractive. There are a number of problems with hotkeys:

  1. They often conflict with screen reader default hotkeys
  2. They must be memorized if they're not obvious
  3. Keyboard input may become trapped by other technologies such as Flash

Contextualizing your keypress capture will help a lot with points #1 and #3 - for example, certain keyboard combinations being only enabled once the table gains focus, or a particular control has been activated.

For vision impaired users, the whole notion of a large, sortable table is problematic from the outset, and such users would benefit from a more wizard-like approach to accessing, sorting and delivering the data, so I think we will keep them as a second priority.

So now we must consider a) your motor impaired users and b) your power-users.

Power users are less of an issue, since by nature, they will be happy to learn and memorize whichever hotkeys they need in order to make them productive. Choosing a logical, consistent schema is your best approach, for example, using the first letter (or first n letters) of the column heading should be sufficient.

Motor impaired users on the other hand will appreciate the most efficient way to access the controls that they will be using most frequently. For this, it's often more important to consider WHERE the control is placed than WHAT the key combination would be. Consider then disassociating the column sorting controls from the physical placement of the table - or rather, make sure that your sorting controls can be navigated to with a minimum of keypresses.

One such strategy might be to implement a simple pull-down menu that can be placed near the top-left (for LTR languages) of the window. Once the pull-down menu gains focus, you can easily open it and select the column you wish to sort by. A nearby control can reverse the order. Pull down menus are typically associated with hotkeys, and they provide a nice visual way of reminding the user what the hotkey is, while providing an alternative method of navigation (arrow keys + spacebar) for people just learning the interface.

By pulling the sorting controls out of the table itself, you give yourself greater breadth for considering all your target audience needs.

1

Here is a superuser.exchange answer to the question

It seems like this is the norm:

I - to Select Arrange Icons by..

N - To Arrange by Name

S - To Arrange by Size

T - To Arrange by Type

M - to Arrange by Modifie

2
  • I think this is very specific for a folder view
    – stefan.s
    May 19, 2014 at 9:00
  • I would argue that the folder view is the most common and users have the most experience with it.
    – jonshariat
    Jun 3, 2014 at 16:40
1

I don't think there's a standard way to do this. As to recommended ways, it depends.

If for some reason your users sort their tables very often (I'd say a couple times an hour or more) and it's an important part of their workflow, then you need to provide a quick shortcut. In that case I'd go with a function key (alt/shift) and a letter representative of the column title, preferably the first.

But the typical case is that users sort tables relatively rarely. In that case you just need to provide a keyboard shortcut as a fallback, or to support some standard or policy (a very commendable standard btw). So it's acceptable if users need to navigate a bit in order to enable the shortcuts - for example they can press Alt+S (for Sort) to highlight the column titles on the screen, and only then press the letter representative of the relevant column title. Another way would be just tabbing through the columns and then pressing Up/Down or maybe Enter to toggle the sorting on that column. This may be the better way when your columns are customizable and there's so many of them that with some combinations you may run out of letters.

Why not always go with the first way? Because you're bound to override some standard shortcuts and because you're taking away quick shortcuts from more important and more frequent actions.

In the second way you absolutely need to provide a graphic expression of this keyboard navigation.

See the way they implemented keyboard shortcuts in MS Word for example. Frequent actions have their fixed shortcuts which are available at all times, and all the other actions are highlighted when you press Alt, and you often need to navigate in order to get to them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.