Keyboard keys not working on CodePen

orbit-controls

#1

I made this project:

Is there an explanation why my keyboard controls aren’t working? If so, is there an easy way to fix it?


#2

I think you run in the same problem like mentioned in the following topic. I’ve posted a possible solution right here: Want to let car ‘drive’ but that doesn’t work, instead the camera moves


#3

I don’t think so. In that case I was interfering with the OrbitControls. With this project things run fine when I run it locally from my computer into Chrome. But when I load it into CodePen the keys won’t work anymore


#4

If you disable the controls they work:


#5

But I need the orbit and zoom controls. Just nog the arrow keys. So I thought I could do this in the JS editor:
controls.enablePan = false;
controls.enableKeys = false;

It disables the pan and the keys, but my keys still won’t work.


#6

Even if you set enableKeys to false, the respective event listeners are already set and active. Hence, you have to enhance OrbitControls to make this work.


#7

I also tried to change it in the orbitcontrols.js file itself. When I run it local it works. Then I upload it to github to link it in codepen (RAW in html editor of codepen) But that doesn’t work


#8

Is the version on RAW equal to your local version?


#9

Yep. Except I link to it from GitHub. So the only possibility is that I link it the wrong way? I just put the RAW URL in the HTML editor with the rest of the scripts


#10

Refused to execute script from ‘https://raw.githubusercontent.com/biancalooijen/projectInteractiveHome/master/OrbitControls.js’ because its MIME type (‘text/plain’) is not executable, and strict MIME type checking is enabled.

This is the error I get in the console when adding my GitHub link to the HTML editor on CodePen.