Photocatalytic H2O2 photosynthesis is limited by inefficient O2 activation, charge recombination and unclear reaction pathways. Herein, K-doped-induced cyano-rich g-C3N4 was constructed via a facile KCl-assisted one-step thermal polymerization using urea as the precursor. The optimized catalyst achieves an H2O2 production rate of 2.19 mmol·g-1·h-1, approximately 15-fold higher than pristine g-C3N4 with an apparent quantum efficiency (AQE) of 1.24% at 420 nm. Comprehensive characterizations reveal that K doping induces cyano group formation and regulates the electronic structure, as evidenced by band structure modulation, surface potential variation and enhanced electron utilization. These changes promote directional electron migration and efficient O2 activation for H2O2 generation. Mechanistic investigations based on EPR spectroscopy, trapping experiments, RDE measurements, in situ DRIFTS, KPFM and DFT calculations reveal that H2O2 production predominantly proceeds through a ·O2−-mediated stepwise oxygen reduction pathway, with additional contributions from direct two-electron ORR, 1O2-involved oxidation processes and the water oxidation reaction pathway. Importantly, cyano groups are suggested to serve as electron-directing centers that facilitate O2 adsorption and reduction. Overall, this work establishes a clear correlation between structural regulation, electronic properties and reaction pathways, providing a simple and effective strategy for designing high-performance g-C3N4-based photocatalysts for sustainable H2O2 production.