Nanogenerators offer a promising solution for converting mechanical movements into electricity with significant implications for portable electronics. Herein, we propose a novel approach using magnesium (Mg)-doped zinc oxide (ZMO) nanoflakes (NFs) embedded in polydimethylsiloxane (PDMS) composite films, which serve as the negative tribo-layer in a triboelectric/piezoelectric hybrid nanogenerator (HNG) operating in contact-separation mode. The ZMO NFs, with an optimized Mg concentration for a high dielectric constant, are mixed into PDMS, and their concentration is further optimized to achieve the highest electrical output from the HNG. The optimized device generates a voltage, current, and power density of approximately 186 V, 5.23 μA, and 1.56 W/m2, respectively while also exhibiting high stability. The electricity generated by this HNG is successfully utilized to power commercial portable electronics. To further enhance its practicality, six similar HNGs were fabricated and integrated into a 3D printed structure, forming a rod-type handheld HNG (RTH-HNG). The energy-harvesting capability of the RTH-HNG is systematically investigated under applied external forces. Additionally, the speed-sensing ability of the RTH-HNG during hand-shaking motions is assessed, with the system demonstrating an accuracy of up to 94 % when compared to a commercially available infrared sensor. Moreover, the real-time vibrational energy harvesting capability of the RTH-HNG was demonstrated by attaching it to a bicycle. Therefore, the proposed RTH-HNG can function not only as a mechanical energy harvester for powering small portable electronics but also as a self-sufficient speed sensor for various real-time applications.