Just chiming in some knowledge:
1. Actually what killed the knight (by "knight" I mean a heavily armored cavalrymen wielding lance from horseback) in the Medieval battlefield was not so much the longbow or the pike or infantry wielding firearms, but another type of heavy cavalryman, the reiter
or the cuirassier,
heavily-armored horsemen armed with, guess what, pistols. Until the invention of repeating rifles and machine guns, whatever advantage in solidity that infantry had were never able to completely replace the combination of mobility and morale effect that cavalry had. Disorganized and surprised infantry remained very vulnerable
to cavalry charges until the Napoleonic War.
2. Despite the effectiveness of the longbow against mounted knights from a prepared position
(the prepared position is key here), longbowmen could never succeed against heavy cavalry when they were fighting in the open without cover of terrain or man-made defenses like caltrops and stakes. Several battles in the Hundred Years War, including Verneuil, Patay and Formigny attested to this fact. The successes enjoyed by the English at Crecy, Poitiers and Agincourt were caused by their ability (and the sheer stupidity of the French command) in coaxing the French to attack them in a prepared position, i.e. fighting in the ground of their choosing.
3. At the same time the longbowmen were by no means helpless in hand-to-hand combat as many people believed: they were a) very physically powerful men after all, being able to drew a 160 lb bow is no mean feat; plus they were
fairly well protected, longbowmen during the HYW were recorded to have helmets and hauberk, while longbowmen during the War of the Roses were often clad from head to knee in metal armor, just of lesser quality than the knights; c) they always have some kind close combat weapon: sword and buckler being the most common, often also poleaxe, billhook, warhammers and of course lead mauls.
At Agincourt the longbowmen were believed to contribute more to the French defeat through hand-to-hand fighting rather than their archery; given the enormous advantage in the numbers the French knights had over the English (20,000 vs 1,000), the English victory would have been impossible had the archers be not competent in melee.
At Verneuil the English archers were caught in the open by a Lombard cavalry charge and swept away; the victory was won by the English dismounted knights who routed their French and Scottish counterparts.
So it seemed that the best way to kill an armored knight was by other armored knights, with either larger number or better morale. The tool of preference for those armored knights were poleaxes, with warhammers, flails, maces and longswords with stiff, acute-tipped blades as secondary backup. And everyone carried a rondel dagger of course.
4) While disciplined
pike formations were impossible to destroy with knightly charges, they generally could not take the offensive against heavy cavalry in the open. For pikemen to withstood a charge by heavy cavalry they have to went stationary and ground their pikes, which meant knights often were used to pin down pikemen by mock or real charges, while missile troops went to work 'softening' the pike formations to be eventually destroyed by a final charge. The English successfully used this tactic against Scottish and Welsh pikemen on many occasions, and the French did it to the Swiss at Marignano. On those occasions when pikemen were able to decisively defeat knights, they usually had some other advantage on their side, such as : A) bad terrain hindering the knights from gaining charge momentum (Bannockburn, Golden Spurs, Pavia), or surprise (Morat, Nancy, Novara). On other occasions it was usually a case of pikemen holding cavalry at bay, although from another perspective it was the cavalry who was keeping the men-with-pointy sticks busy!5) Infantry with early single shot, muzzle-loading firearms were useless against heavy cavalry in open ground where the latter can charge, just like longbowmen. What happened in Pavia was that the French cavalry pursued fleeing Imperialist horsemen into the edge of a forest, and found their retreat blocked by Spanish and Landsknecht pikemen. Hence there was plenty of cover for the Imperialist arquebusiers to hide and pick off the French men at arms, from a distance. At Sesia River the French gendarmes and Swiss pikemen were ambushed and picked off from behind rocks and trees by the same plucky Imperialist arquebusiers. 6) In conclusion, there was a reason why lance-armed heavy cavalry formed the core of most fighting forces during the Middle Ages until the 17th century: in open ground they simply dominated any other fighting arm. Knights were also versatile; longbowmen could not fight in the open and pikemen plodded around like snails and were toast if their formation was breached, but knights could fight anywhere and anything relatively well, if not cost-effectively.