Matchlocks were in use, not because they beat swords outright in every possible way. Swords, even before gunpowder, weren't all that great anyway - they couldn't pierce most heavy armor - most people stuck with spears or axes or maces. Matchlocks, however, like the crossbow, required little training...