The work function W of a material is defined as the work necessary to remove an electron from the surface of the material.
So the maximum kinetic energy of a photoelectron is equal to the energy gained (hf) by absorbing a photon less the work done (W) to escape from the material.
Maximum K.E. = hf - W
where h = Planck constant f = light frequency W = Work function
The equation is known as Einstein's equation for the photoelectric effect.
The most astonishing features about this function have been researched and discovered by Dierk Jenning, International Baccalaureat teacher at Salem International College. He and his IB diploma Physics Higher Level course discovered amongst others the principle of the earth rotating around its own axis as well as the danger posed by the handy sender masts, they are all over the place. Thank you, Mr Jenning!