Mainly the problem is the precision of the color and how the shader interprets it. So using the == comparator means that the color has to be exactly the same, and due to the floating point calculations and the precision of the shader this never happens. Then > and < are used to set a range.
This should work, and best if you have an unfiltered pixelart texture. Increase or decrease the precision parameter according to the range of colors you want to cover.