The crossbow dates back as far as 600 BC. It was used in both Ancient Greece and Ancient Rome. The crossbow was introduced to Medieval Europe in about the 9th century. It was one of the few weapons that was effective against mounted knights in plate armor. This made it an essential weapon for wars during the Medieval and Renaissance period when mounted knights prevailed.
The crossbow as a weapon is just essentially a small bow, called a prod or lath, mounted sideways on a piece of wood, called a tiller or stock. There were many different designs for medieval crossbows. Most were based loosely on the ballista. A ballista was a large siege weapon used to shoot a large bolt over long distances, which was originally made by the Ancient Greeks from their own crossbows. The crossbow had some kind of mechanism for drawing back the bowstring and locking it into place, then it had to have a way to release the string when the time came, like the trigger on a gun. A crossbow could be “cocked” or loaded for hours, and was able to be at ready at all times, keeping the crossbowman from being taken by surprise. The disadvantage, of course, was that it took quite a while to reload after the shot was fired, as opposed to the firing time with a long bow. There were many different ways in which a crossbow could be cocked and loaded. Most involved a bar of some kind to step on with the foot to hold the bow down to the ground while pulling the string back and locking it in place.
The crossbow was not as accurate as the medieval longbow, which took years of practice to achieve this accuracy, not to mention the strength training needed to draw the bow. The crossbow could be used effectively with as little as a week of training, making it the ideal weapon for peasants. The disadvantage of the amount of time it took to reload the crossbow made the crossbowman vulnerable, and so a tall shield called a Pavise was developed to protect them. As a comparison, a crossbow could should only about 2 bolts a minute, whereas a fully trained longbow man could shoot 10-12 arrows per minute, however the longbow man needed many years to achieve this kind of speed, and still did not get the power of a crossbow, and could not kill a knight in armor.