allInputAccessKeys

By Quinn Comendant Last update Apr 16, 2006 — Installed 366 times.
// ==UserScript==
// @name allInputAccessKeys
// @namespace http://www.strangecode.com/
// @description Sets the accesskey for each submit buttons on page to the first letter of the value of the button.
// @include *
// ==/UserScript==
(function () {
    var inputs = document.getElementsByTagName('input');
    for (var i = 0; i < inputs.length; i++) {
        if (inputs[i].getAttribute('type') == 'submit') {
            var matches = /^(\w)/i.exec(inputs[i].getAttribute('value'));
            inputs[i].setAttribute('accessKey', matches[0].toLowerCase());
        }
    }
})();