This sounds like power is not getting to the starter solenoid when you turn the key. The most common cause of this kind of problem is that; on manual transmission vehicles, the clutch pedal switch goes out. That switch, on the clutch pedal, only lets power go to the starter when the clutch pedal is held down. Automatic transmission vehicles do not have a clutch pedal switch; but instead, they have a similar device called a neutral safety switch, which only lets power go to the starter when the transmission is in Neutral or Park. If these switches go bad, they will cause the problem you described.
On automatic transmission vehicles, the Park contact in the neutral safety switch often goes bad while the Neutral contact is still good; so you may find that the truck will still start in Neutral, but will no longer start in Park. Or, it may be necessary to jiggle or press the gearshift lever in order to get the starter to work
On manual transmission vehicles; a bad clutch switch can be bypassed by connecting a jumper between the two wires that go to the switch (located next to the clutch pedal). If you bypass the clutch switch, the starter will then work whenever you turn the key; regardless of whether the clutch pedal is up or down. This can be dangerous for someone who does not realize that the starter motor can then start moving the truck while it is in gear. If you bypass the clutch switch; and the starter still does not work; try the test in the following paragraph to determine whether the problem is in the ignition switch or in the starter or starter solenoid.
You can test to see if these two safety switches are bad, by connecting a remote starter switch or a jumper wire from the battery positive (+) terminal to the small terminal on the starter solenoid where the wire from the ignition switch normally connects. Make sure the transmission is in neutral or park when doing this test. Turn the key on, to the position where the dash lights come on, and then press the remote starter switch or touch the jumper wire to the starter solenoid terminal. If the starter then works, the engine will probably start running; so keep your hands and any tools or rags away from the fan and fan belt.
If this test does not make the starter work, and you have connected the jumper or remote starter wires correctly; then the starter solenoid or starter motor is probably defective.
If this test makes the starter work; then either the ignition switch, or the neutral safety switch, or the clutch switch is bad.