This page attempts to explain how airsoft pistols work.
With the help of photographs and schematics, I'll attempt to describe the way in which air (or gas) is compressed to produce the power to project the BB.
When the slide is pulled back the power spring is compressed.
As the slide is released into its normal position (to which it is returned by the recoil spring), a BB is collected from the top of the magazine and positioned in the receiver at the rear of the barrel.
At this point the gun is ready to fire.
When the trigger is pulled, the power spring is released, which pushes the piston through the nozzle.
Air is driven from the nozzle, behind the BB and down the barrel.
NBBs
Non-BlowBack gas pistols are all double action. They are primed and fired by pulling the trigger.
Gas is fed into a reservoir in the magazine or, on older/cheaper designs (eg Tokyo Marui's NBB range, excluding the MK23 and new 1911), in the handgrip.
When the trigger is pulled the barrel assembly is pulled back and a BB collected from the top of the magazine.
As the trigger is pulled further the hammer hits the gas release on the magazine (or in-built gas reservoir).
The gas is channeled from the magazine/reservoir, into the back of the barrel and then down to push the BB out of the barrel.
GBBs
Gas Blow Back pistols are the most complex, but most realistic, type of airsoft gun.
Some are Double Action, some are single action, depending upon the nature of the real-steel gun they are replicating. In the case of single action guns, they need to be cocked first, usually by racking the slide or a cocking handle on something like a Micro UZI or Mac 11.
This collects the first BB for firing and readies the mechanism for firing. On double action guns, this is achieved by simply pulling the trigger.
Once the gun is cocked, pulling the trigger causes the gas release (connected to the hammer in the case of the Beretta M9 shown above) to hit the gas release valve on the magazine.
The gas is channeled up to the power valve, which is pushed through the nozzle, forcing the BB down the barrel. (Past the Hop-Up in the M9's case, which puts back spin on the BB for extra range).
Once the BB is released, the valve blocks the barrel and remaining gas is used to drive the slide backwards, where it resets the mechanism ready to fire again.
The slide reaches the point where the recoil spring is fully compressed and then is forced to return to its normal position, as the recoil spring releases. As it does, it collects the next BB from the magazine and is ready to fire again.
Gas Revolvers
Most revolvers (spring and gas) work in a similar fashion. A notable exception to this is the PEGASUS system employed by Tanaka, where the gas and BBs are held in a cylinder which works like a magazine, rather than using shells. As I've never seen a Tanaka, I'll not try and explain who it works, but all reports suggest it produces very good power.
Anyway, the majority of gas revolvers (which use removable shells) work thus :
Gas is fed into a reservoir, in the handle of the gun (note that this usually precludes use of real steel grips on airsoft revolvers).
BBs (sometimes up to 4, but don't ask me how this works - best explanation I've heard is "it's magic"!) are placed in removable shells, which are placed, like the real thing, into the cylinder.
Pulling the trigger rotates the cylinder one place, cocks the hammer and causes the gas release (connected to the hammer in the case of the KWC Revolver shown above) to hit the gas release valve on the reservoir - This is the case with double action revolvers (as most are).
It is also possible to rotate the cylinder and cock the hammer, simply by pulling back the hammer. Pulling the trigger will fire the weapon as before. This is a single-action mechanism, but is very rare in isolation, rather it's an option for better accuracy (and lighter trigger pull) on double action revolvers. - Spring revolvers are all single action and compress air in a reservoir, by cocking the hammer.
The gas is channeled up to the cylinder, forcing the BB from the cartridge and down the barrel. Sometimes this route can be circuitous and often has many places where gases can leak, making revolvers less powerful airsoft weapons, generally.