button: add ui-state-active on keydown, further improving keyboard navigation - doesn't yet work properly for anchors and radio/checkbox buttons

This commit is contained in:
Jörn Zaefferer 2010-01-22 22:46:32 +00:00
parent cc77201c8e
commit 967454c434

View File

@ -128,6 +128,14 @@ $.widget( "ui.button", {
return;
}
$( this ).removeClass( "ui-state-active" );
})
.bind( "keydown.button", function(event) {
if ( event.keyCode == $.ui.keyCode.SPACE || event.keyCode == $.ui.keyCode.ENTER ) {
$( this ).addClass( "ui-state-active" );
}
})
.bind( "keyup.button", function() {
$( this ).removeClass( "ui-state-active" );
});
}