Living cells adapt and respond actively to the mechanical properties of their environment. In addition to biochemical mechanotransduction, evidence exists for a myosin-dependent purely mechanical sensitivity to the stiffness of the surroundings at the scale of the whole cell. Using a minimal model of the dynamics of actomyosin cortex, we show that the interplay of myosin power strokes with the rapidly remodeling actin network results in a regulation of force and cell shape that adapts to the stiffness of the environment. Instantaneous changes of the environment stiffness are found to trigger an intrinsic mechanical response of the actomyosin cortex. Cortical retrograde flow resulting from actin polymerization at the edges is shown to be modulated by the stress resulting from myosin contractility, which in turn, regulates the cell length in a force-dependent manner. The model describes the maximum force that cells can exert and the maximum speed at which they can contract, which are measured experimentally. These limiting cases are found to be associated with energy dissipation phenomena, which are of the same nature as those taking place during the contraction of a whole muscle. This similarity explains the fact that single nonmuscle cell and whole-muscle contraction both follow a Hill-like force-velocity relationship.