How To Mind Control Your Chrome Dinosaur

Chrome t-rex running game

Specifically… our Chrome dino buddy. The one that helps you out when you have bad internet connection.

I’m guessing you play the chrome dino game with your space bar, but that’s old school now. What if I told you, you could control this dinosaur game with your mind? Let me show you how.

How Does This Work?

Controlling the chrome dinosaur works by using a Brain Computer Interface (BCI). At a high level, brain-computer interfaces measure and send your brain wave data to an external output, allowing us to analyze, manipulate, and control devices like your computer! Check out my blog on a deeper intro to BCIs and how they work.

In this project, I use a Muse EEG Headband to detect eye blinks. This is because blink artifacts are one of the most influential brain waves for electroencephalograms (EEG) to detect and for our computer software to clearly interpret.

With some code, you can translate your blink artifacts into commands to your computer, allowing you to control the dino game with your mind! Let’s get started.

  • 2016 Muse EEG Headband
  • Computer (I used a Mac)

And… that’s pretty much it.

The Process

This blog was super helpful in guiding me through the process.

First, I need a standalone HTML page with the chrome dino game. This way, I can connect my Muse Headband via Web Bluetooth.

Clone this github repo by typing this in the terminal:

git clone

Now that you’ve cloned this, go into the directory trex-runner on your terminal and initialize a new NPM project:

npm init -y

Next, we need to install muse-js because we reference this code in order to add special web bluetooth functions and eeg-reading functions to the plain HTML dino game:

npm install --save muse-js

We will also need to install the module loader SystemJS:

npm install --save systemjs

Okay, now you that you have everything installed, we can start adding in some code to the trex-runner repository that we cloned. I used Visual Studio Code, but you can use any editor you prefer.

Coding the Game

Go into the index.html file and paste this code:

This code defines and tells the code where to locate muse-js and rxjs modules.

Line 18 calls the file brain.js , so we need to create that file in the repo and add this code in it:

Lines 11–15 filter the blinks for the left eye, since we are looking at the AF7 electrode, not the AF8 electrode, which records the right eye. However, I can’t wink so i’ll just be blinking with both eyes, essentially not making a difference which eye I choose.

Line 17 calls subscribe, so that it can start paying attention to the blink artifacts.

Line 15 is important to remember, since this is where a lot of tinkering and trial and error will take place. Right now, the threshold is set at 150 because that is what worked best for me, but depending on your brain activity you will need to adjust this. I will explain this more later.

Now, we need to replace the inside of the blinks.subscribe function with this code:

This changes the code from just printing “Blink!” to actually stimulating a DOM keydown event which basically makes the game interpret a blink as a spacebar click. Now your dinosaur will jump at blink of an eye rather than the click of your space bar.

The last code we need to insert is a button to click so we can pair and connect our Muse headset to the browser. Insert this code in your index.html file:

There you have it! That’s all the code you need to play the dino game just by blinking!

Tips When Coding

As I was coding this, I faced a lot of errors and had to troubleshoot a lot, but I learned a few tricks here and there that can be helpful for you, especially if you’re a beginner at this.

I had a lot of trouble connecting my muse headband to the browser in the first place. It was hard to see if my muse was even able to connect, and I didn’t even know if my brain signals were being detected in the first place. Here’s what helped me with this:

  • Visualize your brainwaves to get an idea. you can use this live Muse EEG Explorer, or you can run the muse-js code itself on a live server
  • Speaking of running code on a live server, I wasn’t even sure how to do this at first. The way found I like to do it is installing yarn and running it in the directory you want:
yarn installyarn start

Then, your code will run on a local web browser without actually running on a site, and you can visualize your brain waves. This is also how you can run the main trex-runner game (that’s how I did it).

Another big problem I ran into was figuring out the best threshold to actually play the game well.

Lower thresholds means your dinosaur will jump at lower levels of brain waves, making it slightly more sensitive to jump events. In a less noisy environment, thresholds between 150 and 200 seem to work well. But in noisier environments, 400–500 seems to work best.

For me, after a lot of trial and error, I found that a threshold of around 100 and lower was too sensitive for me, and a threshold of 250 was not sensitive enough. I found 150 to be the best threshold for me to play.

It all depends on your brain activity, so after some trial and error, you can figure out the best threshold that works for you. Here are some video demos of high, low, and ideal sensitivity levels when playing and figuring out what works best:


This was the best game for me, so evidently my brain works better at a threshold of 150. Here’s a demo of what this looks like:

And just like that, after a few lines of code and experimenting, you can see how easy it really is to control your computer with your brain! This is just a basic level example of what brain computer interfaces can do. It can control wheelchairs, prosthetic arms, help the visually impaired communicate, and so much more — with just their brain!

If you enjoyed this blog, give it a clap and follow me on my journey researching BCIs and other emerging technologies to change the world for the better! Feel free to connect with me on LinkedIn to chat as well :)