The current technological level is a cross between medieval and the american west. Basically, I want a world where melee weapons are either incredibly inefficient, or incredibly rare (only kings and warlords would have the resources for even a single sword or shield, maybe a handful if they are remarkably wealthy).
I'm going to focus on the goal of medieval gunslingers, rather than the suggested solution of making good metal scarce. I already have an answer about making low pressure guns from inferior materials, but @not store bought dirt's answer about making swords and armor obsolete with better guns earlier is very compelling. I'm going to expand on it.
How much history and technology has to change to have medieval gunslingers? Not much.
Flintlock Muskets Made Swords, Pikes, and Armor Obsolete
Certainly by the time of the Seven Year's War, 1754 - 1763, possibly earlier, armor and melee weapons were obsolete. The gun was supreme, at least in Europe. The melee weapon's last hurrah was the bayonet to repel charges, turning your musket into a makeshift pike.
The guns of this era were black powder, muzzle-loading, flintlocks, sometimes rifled, sometimes not. They were sufficient to render swords, pikes, arrows, and armor obsolete. The British Brown Bess is a fine example.
Black powder, as opposed to modern smokeless powder, burned slower, developed less pressure, and left a lot of residue fouling the barrel and needing a lot of cleaning. Still, it worked, and it would be the powder of choice until the late 1800s. The low pressure required long barrels to build up velocity.
Muzzle-loading meant a laborious process of dropping powder and ball down the barrel and packing it in. For single shot rifles, this was a 15-20 second process. Revolvers and multi-barrelled weapons dealt with this problem by providing multiple pre-loaded chambers.
A flintlock is the mechanism by which the powder is ignited. A piece of flint strikes a piece of steel creating sparks that fly into a pan of powder which ignites the full charge. This was a great advance over the previous unreliable matchlock, a slow burning rope and not so good in the damp, and cheaper than the more reliable but expensive wheellock. The flintlock meant your gun would be ready to fire in any weather condition, at a moment's notice, and at a reasonable price.
Medieval Flintlock Muskets and Revolvers
True flintlocks appeared in Europe in the early 1600s, but as far as I can tell, there's nothing technologically insurmountable about a medieval flintlock. Simple springs were available, and the idea of flint striking steel to make a spark was ubiquitous. Perhaps an improvement in metallurgy and spring steel.
Black powder was known in China since the 10th century, and news reached Europe by the 13th century. The secret of black powder could have arrived in Europe earlier, or it could have been invented by some European alchemist. Having black powder in an alternate medieval setting is not a problem.
Smooth bore barrels and chambers for black powder were far easier to make than rifled barrels and chambers withstanding the high pressures of smokeless powder.
Your medieval gunslingers might be carrying something like these Collier Flintlock Revolvers. Each chamber of the revolver would be loaded just like a little muzzle loader, and it would be fired just like a flintlock.
There's no need to exclude metal, flintlock muskets and revolvers are enough to explain why your medieval knights don't wear armor and carry swords. And they can be made available to a medieval society without much change. You can go further down this road, but it pushes into places with broader effects on technology and society.
Next Step: Percussion Caps
The next step in the firearms progression is the percussion cap. This replaces the flintlock with a little button of contact explosive, like fulminate of mercury. You pull the trigger, a spring loaded hammer smacks into the cap, it goes bang and ignites the powder. Far, far, far more reliable than a flintlock. We use the same basic idea today, except it's built into the cartridge and called a "primer".
The problem is, fulminate of mercury wasn't invented until 1800. It requires a model of chemistry and a chemical industry to produce pure chemicals that would radically alter a medieval setting. I'd be wary of going down this road.
Instead use the unreliability of flintlocks as a plot device. Percussion caps might be an expensive secret known only to a few alchemists who stumbled upon it, but have difficulty reproducing it because of the impure chemicals they're using and lack of understanding of chemistry.
Next Step: Breech Loaders
Breech-loading guns, like all modern guns, greatly speed loading by loading from the chamber instead of from the end of the barrel. It allowed the next big innovation, cartridges.
While they were around since the 14th century, breech-loaders didn't really catch on until the 19th. The problem is sealing the breech reliably against very high pressures. Until the invention of the metallic cartridge (see below) this required careful machining and excellent metallurgy.
In your setting, breech-loaders could be expensive, exotic items.
Next Step: Paper Cartridges
Once you have a breech loader, you can wrap your powder and ball in paper, seal it with wax, and have an all-in-one package to stuff into the chamber: a paper cartridge.
These effectively work like modern bullets, but they don't seal the breech like a metallic cartridge does.
There's no special technology required, once you have breech loaders you can have paper cartridges. They were used in at least the late 1500s, probably earlier.
Next Step: Metallic Cartridges
Once you have paper cartridges and percussion caps, the next step is metallic cartridges with a built in cap (the primer) resembling modern bullets.
.50-90 Sharps, a black powder metallic cartridge
They're more reliable and resilient than a paper cartridge, but much more important, they solved the problem of sealing the breech. Bullet cases are made out of brass because brass expands slightly under the pressure of the gunpowder. This expansion seals the breech without requiring extremely fine machining. It allows higher pressure loads, and larger, higher velocity projectiles with better range, accuracy, and stopping power.
The metallic cartridge also allows magazines; now you can have multiple rounds, stacked and ready, and fed into the gun by a spring like a modern firearm.
Up to you whether you want to introduce metallic cartridges. It requires percussion caps, with their aforementioned chemical consequences, and breech loaders.
Next Step: Smokeless Powder
As mentioned, black powder burned relatively slowly requiring a long barrel for the projectile to take full advantage It produced a lot of smoke, making it difficult to see what you're shooting at after a few shots. And it left a lot of residue, fouling the gun requiring frequent cleaning, affecting accuracy, and causing malfunctions.
Smokeless powder fixed all that. It burns extremely fast developing high pressure, and thus high velocity, very quickly. It leaves little smoke or residue, allowing for continuous, accurate fire.
Smokeless powder wasn't invented until the mid-1800s. Like percussion caps, it required an existing chemical industry that would radically transform a medieval society. I'd leave this one out.
HOWEVER! Firearms Radically Changed and Expanded Warfare
Good firearms made war cheaper and more lethal, especially the development of drill and volley fire. Instead of the strength of a soldier coming from their own muscle and years of careful training, it comes from the barrel of a gun. Now some peasant with a musket can take down your best trained swordsman. Its cheaper and more effective to give some peasants muskets, drill them for a little while, and call them an army than it is to spend years training swordsmen.
Pikes and crossbows has a similar effect of making warfare cheaper. With a little training, pikes turn a mob of poorly trained troops into a pointy wall. Crossbows give you instant archers without the years of careful training to pull a bowstring. But they're not necessarily more lethal.
Melee warfare was usually less about killing the other guy and more about breaking their morale and formation. Once they broke and ran, then the killing started. Prolonged fights in close combat were more like a tug-of-war, the push of pike, than a Hollywood melee. Muskets and cannon suddenly ramp up the sustained lethality of warfare.
Muskets and cannon meant you could deliver a killing blow from beyond arms reach of the enemy. Everyone, not matter their skill, was now vulnerable. And gunpowder meant you could sustain this fire for as long as the powder and shot held out, no longer would warfare be limited by the physical exhaustion of the troops. Cannons could destroy city walls and mow down lines of infantry throwing city defenses into turmoil.
Once you introduce ubiquitous firearms into your medieval setting, you'll have to deal with this problem. You could take a page from Japanese history: show initial great enthusiasm for the gun with a period of great expansion and great warfare, then retreat from the gun and large-scale warfare with a more isolationist mindset. Perhaps a series of peasant revolts used cheap firearms to attack the heavily armored but less numerous nobility.
Your society and culture, after experiencing a few generations of the ravages of warfare with large armies equipped with firearms, decides to fall back on a more chivalrous, ritualized, small-scale approach to warfare. This still involves firearms, but warfare is a game of the nobility. Gentleman's agreements, like medieval arms treaties, limit the size of standing armies and number of guns to prevent all-out-war or a peasant revolt.