📜 ⬆️ ⬇️

Web without a mouse

Probably, when you look at this screen, everyone mentally transfers both hands to the keyboard. Yes, it was possible to navigate without a mouse, and it was fast and good! Many still use such managers (Total commander, Far etc).

On the other hand, almost on all modern websites, portals and solutions built for the web, the user is forced to constantly take his hands off the keyboard, aim the mouse at the button / icon / field, and then return hands to the keyboard again to enter text.

How to achieve the convenience of navigation without a mouse on the web?

')
Most of the products that our company develops and implements come out to the end user. Call center operators, engineers, managers - they all work with the user interface “for internal use” - B2B interfaces. The ability to work with the system from the keyboard without using a mouse is an important requirement in B2B interfaces. Why?



Such navigation may not look “sexy” and require more time for training, but the bonuses from use significantly exceed these disadvantages.

So, the task


There are a large number of web-based user interfaces. It is necessary:


We analyze


There are four main approaches to keyboard navigation, consider them:


Tabs

Tabulation - transition between interface elements using the tab key (shift + tab).



Hotkeys

Hotkeys (popularly hotkeys) - a combination of keys that calls a particular function. This allows you to simplify access to the main functions of the system. More and more sites are starting to use hotkeys on their pages to access the most requested features, among them: Habrahabr, Yandex, Google Mail and others. But what to do if there are many functions and each page is different? It will simply be impossible to remember all hotkeys, which means that the use will not be effective. There is also a context problem: when there are several tables on the page and several save buttons, for example.


Example implementation: extensions for Firefox use the hotkeys approach, very common in desktop applications (for example, an outlook).


Spatial navigation

When elements on web pages were positioned using css, tab navigation ceased to cope with its task: the cursor jumped over the design elements in the order they were declared in the html document, and not in what the user sees. Then some browsers (Firefox, Opera) implemented spatial navigation. They allowed users to use shift + arrow combinations to move between design elements, with the next element being determined based on its actual location on the screen.



Move the carriage

The peculiarity of this approach is that the user's cursor moves not only by the form elements and links, but by the entire page content (as in the Word). You can move, as in the spatial approach, in four directions.



The above solutions as is not suitable for us due to the lack of support in all browsers, they lack the ability to fine-tune for specific pages, and we would like the hot-keys and spatial navigation to be configured uniformly in one place.

Introducing Mouseless




Key features of Mouseless are:



Mouseless working principle

The page is divided into blocks using the usual CSS selectors. Blocks can have child blocks. Each block has its own set of hotkeys (JSON object). Hotkeys can be inherited by internal blocks, i.e. hotkeys have a scope that can be controlled (for example, a hotkey for saving is the same in different blocks, but it works differently depending on the current block).


The figure shows the division into blocks and subblocks.

The configuration of each block is a json object, json objects for all blocks form the page configuration.

Spatial navigation in this case is a special case of hotkeys. Minimizing the number of required configuration parameters, basic support should be available with a minimum of actions. The simplest configuration:
new MouselessBlock({ //  selector: "#blockId", //     childSelector: “a”, //         keys: [ //    ,     new MouselessAction({key: ncKey.KEY_LEFT, action: ncKey.gotoPrevElem }), //          new MouselessAction({key: ncKey.KEY_RIGHT, action: ncKey.gotoNextElem }) ] }); 

Inside the #blockId block, you can move the focus between the links with the left and right keys. gotoPrevElem / gotoNextElem utility functions, you can also use your custom functions.

On real cases we extend the base library:



Block configuration using the example of NavigationTree (expanding tree):
 new MouselessBlock({ selector: "#navigationTree", childSelector: "li > a:visible", ring: true, keys: [ new MouselessAction({key: ncKey.KEY_LEFT, action: ncKey.gotoPrevBlock, ctrl: true}), new MouselessAction({key: ncKey.KEY_RIGHT, action: ncKey.gotoNextBlock, ctrl: true}), new MouselessAction({key: ncKey.KEY_UP, action: ncKey.gotoPrevElem, ctrl: false}), new MouselessAction({key: ncKey.KEY_DOWN, action: ncKey.gotoNextElem, ctrl: false}), new MouselessAction({key: ncKey.KEY_RIGHT, action: openNavTreeNode, ctrl: false}), new MouselessAction({key: ncKey.KEY_LEFT, action: closeNavTreeNode, ctrl: false}) ]}); 

Now you can walk along the tree with up-down arrows, open-close branches left-right. The openNavTreeNode / closeNavTreeNode functions were written before implementing Mouseless (were published as api to the tree).

Thus, even in this case, it was not necessary to write a new code, we manage with a simple configuration.
CSS is easily replaced by any theme; it’s enough to describe the rules for highlighting the activated and active elements. You can add your own, more complex, for specific blocks or elements.

Total


By implementing Mouseless into our solutions, we received a library that allows us to provide quick basic support for keyboard navigation, on the one hand, and deep tuning for maximum efficiency and ease of use, on the other.

An added bonus was that we covered some of the W3C “Web Content Accessibility Guidelines” recommendations ( www.w3.org/TR/WCAG20 ).

The work in this direction is not finished, we will continue, we are waiting for the reaction of the community.

Source: https://habr.com/ru/post/273071/


All Articles