If an external keyboard isn't working after not being used for a long time, the most likely reason is ***dirt or debris buildup on the keys***, causing poor connection between the key switches and the circuit board; this is especially common with mechanical keyboards where dirt can easily accumulate under the keycaps.
To keep an external keyboard clean when not in use, store it in a dust-free environment, ideally using a dedicated keyboard cover or a clean cloth to prevent dust accumulation; regularly clean it with compressed air to remove debris between the keys, and occasionally wipe down the surface with a slightly damp microfiber cloth if needed.