Skip to content
Sign upLog in

Color Search

Profile icon

Color Search

Hi everyone, I made a program which allows you to search for colors. This was a very cool project for me to do as I used a webscraper to scrape all the color data into a json and used readchar instead of input to enable the updating search feature.

Make sure your console view is large enough so you can see the search results properly.

How to use

Let's say you're creating a website and need the perfect color for your header. You'd like a color which is pretty medium, but are not sure which one to pick. Start by searching medium and you'll see a list of colors which contain 'medium' in their name.

Screenshot 2020-06-19 at 1.45.22 PM

Oh cool, I want to use medium spring green in my project. Type the color you would like to use into the search bar and then hit enter.

Screenshot 2020-06-19 at 1.47.26 PM

Nice right!

How I made it

First of all, I needed to create a dictionary with the color name as the key and a dictionary with the hex and rgb values as the value. Since the data is correlated and jsons are cool, dictionaries were the perfect choice.

I created a webscraper to scrape the color table on If you want to see the code, click here. The webscraper formats the data and dumps it into a json file.

Now that the color dictionary was complete, I focused on the search functionality. I wanted the search results to update every time the user pressed a key so input() wasn't going to cut it.

Instead, I used readchar which is a library that handles single keypresses. Using this, I could update the search results at each keypress, clearing the screen in between.

Since I was using readchar and not input, I had to check if the user entered "Enter" or "Backspace" and respond accordingly. Quick trick: to figure out the codes for keys like enter and backspace, use this.

import readchar key = readchar.readkey() print(key.split("\\"))

Turns out that splitting at the forward slash gives you the code. Note that there are 2 's because you need to escape it.

I also used the RGB ANSI escape code to color the unicode box.

Color Search:
Colors Webscraper:

You are viewing a single comment. View All
Profile icon