There are three kinds of keys and locks that you'll commonly come across: round, square, and triangular. Each key will only work on the matching lock - round key to round lock and so on. Keys weigh next to nothing (124 g a piece) and are incredibly useful; unlocking chests and doors is far better than trying to kick or blow them open. Try to 'collect them all' if you can.
Hexagonal and octagonal keys/locks are much rarer, as well as being black in color. These are found on the hidden Chests in Chest Rooms and on doors in buildings such as the Cathedral in Attnam. If you happen to find one in a dungeon or in a shop, make every effort to get your hands on it. They can also be wished for if you possess a Scroll of Wishing.