Gems are items used to open doors in Keen 4, Keen 5, and Keen 6. They come in red, blue, yellow and green colors. In order to open a door, the gem is placed in a holder of the corresponding color. The door then moves backwards, becoming part of the background and allowing Keen to pass.
It is unclear whether gems are a more or less advanced technology than keycards or keys, although it would seem that all red gems activate all red doors, so Keen could simply keep four gems on his person and never have to look for keys again. Unfortunately, this is not possible in the game.