- // Trigger function if pressed Enter - keyboard navigation
- if ( e.type === 'click' || e.keyCode === 13 ) {
- // When using keyboard, move focus back to the new tag field.
- if ( e.keyCode === 13 ) {
- $( this ).closest( '.tagsdiv' ).find( 'input.newtag' ).focus();
- }
-
+ // On click or when using the Enter/Spacebar keys.
+ if ( 'click' === e.type || 13 === e.keyCode || 32 === e.keyCode ) {
+ /*
+ * When using the keyboard, move focus back to the
+ * add new tag field. Note: when releasing the pressed
+ * key this will fire the `keyup` event on the input.
+ */
+ if ( 13 === e.keyCode || 32 === e.keyCode ) {
+ $( this ).closest( '.tagsdiv' ).find( 'input.newtag' ).focus();
+ }
+
+ tagBox.userAction = 'remove';