JavaScript for handling Tab Key press

javascript

Solution

You should be able to do this with the keyup event. To be specific, `event.target` should point at the selected element and `event.target.href` will give you the href-value of that element. See mdn for more information.

The following code is jQuery, but apart from the boilerplate code, the rest is the same in pure javascript. This is a `keyup` handler that is bound to every link tag.

$('a').on( 'keyup', function( e ) {
    if( e.which == 9 ) {
        console.log( e.target.href );
    }
} );

jsFiddle: http://jsfiddle.net/4PqUF/

Problem

As we know, when we click on TAB key on keyboard, it allows us to navigate through all active href links present open webpage. Is it possible to read those urls by means of JavaScript? example: ``` function checkTabPress(key_val) { if (event.keyCode == 9) { // Here read the active selected link. } } ```

Original source

Related problems