georgealways / lil-gui

Makes a floating panel for controllers on the web. Works as a drop-in replacement for dat.gui in most projects.

Home Page:https://lil-gui.georgealways.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NumpadEnter doesn't blur input fields

Pickleheaded opened this issue · comments

HI,
Should pressing the enter key on a number controller invoke onFinishChange()?

I see there is the following

const onKeyDown = e => {
if ( e.code === 'Enter' ) {
this.$input.blur();
}
if ( e.code === 'ArrowUp' ) {
e.preventDefault();
increment( this._step * this._arrowKeyMultiplier( e ) );
}
if ( e.code === 'ArrowDown' ) {
e.preventDefault();
increment( this._step * this._arrowKeyMultiplier( e ) * -1 );
}
};

Thank you!

Ok, I tried this on a few different keyboards and suddenly realised nothing was happening because I was inputting data using the number keypad and pressing the number key pad 'Enter Key'.

Could const onKeyDown be changed to include NumpadEnter as below?

const onKeyDown = e => {
if ( e.code === 'Enter' || e.code === 'NumpadEnter' ) {
this.$input.blur();
}
if ( e.code === 'ArrowUp' ) {
e.preventDefault();
increment( this._step * this._arrowKeyMultiplier( e ) );
}
if ( e.code === 'ArrowDown' ) {
e.preventDefault();
increment( this._step * this._arrowKeyMultiplier( e ) * -1 );
}
};

Thank you!

Good catch. Looking at this, it seems like we could use e.key === 'Enter' to capture both. Either way, numpad enter should work here—thank you!

Hey! This should be fixed as of 0.18.2