Does the gun mechanism work in space?
Yes, it does, but for only one shot. In space there are no forces acting on the gun, the bullet or the astronaut. When the astronaut pulls the trigger the hammer hits the primer of the round. The Primer combusts instantly and ignites the gunpowder. The powder has enough air with it in the cartridge to burn in spite of the vacuum of space. The expanding gases in combination with the vacuum outside propels the bullet down the barrel and out of the gun. This is in keeping with Newton's 1st and 2nd laws of motion. However, the lynchpin is Newton's 3rd Law. The recoil of the gun will propel the astronaut in the opposite direction, until another force acts on the astronaut to stop him/her.