diff --git a/src/components/library-item/library-item.jsx b/src/components/library-item/library-item.jsx index 3ae49f1553d3b93caf2aaa0ef67152ef3f80ba12..04e5c08056b05d7247f34dde0d558ce9c99b2a9b 100644 --- a/src/components/library-item/library-item.jsx +++ b/src/components/library-item/library-item.jsx @@ -13,6 +13,7 @@ class LibraryItem extends React.PureComponent { 'handleBlur', 'handleClick', 'handleFocus', + 'handleKeyPress', 'handleMouseEnter', 'handleMouseLeave' ]); @@ -27,6 +28,12 @@ class LibraryItem extends React.PureComponent { this.props.onSelect(this.props.id); e.preventDefault(); } + handleKeyPress (e) { + if (e.key === ' ' || e.key === 'Enter') { + e.preventDefault(); + this.props.onSelect(this.props.id); + } + } handleMouseEnter () { this.props.onMouseEnter(this.props.id); } @@ -61,6 +68,7 @@ class LibraryItem extends React.PureComponent { onBlur={this.handleBlur} onClick={this.handleClick} onFocus={this.handleFocus} + onKeyPress={this.handleKeyPress} onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave} >