A new photoelectric phenomenon in a solid, the in-plane photoelectric effect, has been recently discovered in a GaAs/AlxGa1−xAs heterostructure with a two-dimensional (2D) electron layer (W. Michailow et al., arXiv:2011.04177). In contrast to the conventional photoelectric effect, the inplane effect is observed at normal incidence of radiation, the height of the in-plane potential step, which would correspond to the work function in the conventional photoelectric effect, is electrically tunable by gate voltages, and the effect is maximal when Fermi energy lies above the potential barrier. Based on the discovered phenomenon, efficient detection of terahertz radiation has been demonstrated. In this work we present a detailed analytical theory of the in-plane photoelectric effect providing results for the terahertz wave generated photocurrent, the quantum efficiency, and the internal responsivity in dependence on the frequency, the gate voltages and the geometrical parameters of the detector. The calculations are performed at zero temperature.