Gran Telescopio Canarias OSIRIS transiting exoplanet atmospheric survey: detection of potassium in XO-2b from narrowband spectrophotometry