Giter VIP home page Giter VIP logo

Comments (5)

Mugen87 avatar Mugen87 commented on June 16, 2024 1

OrbitControls like other control classes rely on KeyboardEvent.code which represents the physical key on the keyboard. This is ideal for all use cases where the user is supposed to control an object/camera with fixes keys on the keyboard (think of games which rely on WASD or arrow keys).

Add keycodes PLUS: 107, MINUS: 109 to this.keys.

Regarding plus and minus, using the numeric key code values doesn't work since the control classes check for KeyboardEvent.code. So the + and - signs are e.g. NumpadAdd and NumpadSubtract when using the numpad. However, not all keyboards have a numpad so their plus and minus keys might be at different positions. I wonder if it is better to make a second switch statement in handleKeyDown() and check for KeyboardEvent.key instead. Meaning:

switch ( event.key ) {

	case '+':

		dollyOut( getZoomScale() );
		needsUpdate = true;
		break;

	case '-':

		dollyIn( getZoomScale() );
		needsUpdate = true;
		break;

}

@felixmariotto Plus and minus signs are not that established as WASD or arrow keys in context of gaming. It seems checking for the actual character seems better in this case, imo. What do you think?

from three.js.

Mugen87 avatar Mugen87 commented on June 16, 2024

I like the idea of support keys for zoom but the suggested change does not work for me. E.g. on macOS the code for plus on the numpad is NumpadAdd.

from three.js.

LeviPesin avatar LeviPesin commented on June 16, 2024

Wouldn't it be even better to replace all usages of KeyboardEvent.code with KeyboardEvent.key? The second would be more understandable because of comparing with the character instead of some abstract keycode.

from three.js.

Mugen87 avatar Mugen87 commented on June 16, 2024

KeyboardEvent.code is the better default for controls with has been approved in #21056. I don't think there is a need to question this policy. It definitely makes sense for many use cases. There might be exceptions like this issue though.

from three.js.

Mugen87 avatar Mugen87 commented on June 16, 2024

Closing, see #26862 (comment).

from three.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.