Recent experiments show that the neural codes at work in a wide range of creatures share some common features. At first sight, these observations seem unrelated. However, we show that all of these features of the code arise naturally in a simple threshold crossing model when we choose the threshold to maximize the transmitted information. This maximization process requires neural adaptation to not only the d.c. signal level, as in conventional light and dark adaptation (for example), belt also to the statistical structure of the signal and noise distributions. Interestingly, if we fix the threshold level, we can observe a peak in the transmitted information at a finite value of the input signal-to-noise ratio. However, when we allow the threshold to adapt to the statistical structure of the signal and noise, the transmitted information-is always monotonically increasing with increasing input signal-to-noise ratio.