Keyhole porosity is a key concern in laser powder-bed fusion (LPBF), potentially impacting component fatigue life. However, the dynamics of keyhole porosity formation, i.e., keyhole fluctuation, collapse and bubble growth and shrinkage, remain unclear. Using synchrotron X-ray imaging we reveal keyhole and bubble behaviours, quantifying their formation mechanisms. The findings support the hypotheses that: (i) keyhole porosity can initiate not only in unstable, but also transition keyhole regimes, created by high laser power-velocity conditions, causing fast radial keyhole fluctuations (~ 10 kHz); (ii) transition regime collapse tends to occur part way up the rear-wall; and (iii) immediately after keyhole collapse, the bubble grows as pressure equilibrates then shrinks due to metal-vapour condensation. Concurrent with condensation, hydrogen diffusion into the bubble slows the shrinkage and stabilises the bubble size. The physics revealed here can guide the development of real-time monitoring and control systems for keyhole porosity.