Sha256: 334ccd7fee4a6c5c93012e83a85ce701f2c201f5a375fb95b364c9070c08cc1e
Contents?: true
Size: 1.03 KB
Versions: 31
Compression:
Stored size: 1.03 KB
Contents
// javascript 'shim' to trigger the click event of element(s) // when the space key is pressed. // // Created since some Assistive Technologies (for example some Screenreaders) // Will tell a user to press space on a 'button', so this functionality needs to be shimmed // See https://github.com/alphagov/govuk_elements/pull/272#issuecomment-233028270 // // Usage instructions: // GOVUK.shimLinksWithButtonRole.init(); ;(function (global) { 'use strict' var $ = global.jQuery var GOVUK = global.GOVUK || {} GOVUK.shimLinksWithButtonRole = { init: function init () { // listen to 'document' for keydown event on the any elements that should be buttons. $(document).on('keydown', '[role="button"]', function (event) { // if the keyCode (which) is 32 it's a space, let's simulate a click. if (event.which === 32) { event.preventDefault() // trigger the target's click event event.target.click() } }) } } // hand back to global global.GOVUK = GOVUK })(window)
Version data entries
31 entries across 31 versions & 2 rubygems