There are three kinds of dashes, each a bit longer than the other. You don't need to put spaces before or after dashes (in the US).
Use the hyphen (-) for hyphenating words.
Use the en dash (–) where you would use "to," as in "business hours are 10 A.M. – 5 P.M.," in a range of numbers (pages 17–25), or to link certain compound adjectives like "the Tokyo–Hong Kong flight" or "anti–blood clotting serum."
Use the em dash (—) instead of parentheses—as is done here—to set off a parenthetical phrase. On the typewriter, two hyphens stood in for this dash.
The keyboard shortcuts are: Alt+0150 for an N dash Alt+0151 for an M dash or two hyphens in a row