you can't
How do I learn openings?
say a SPECIFIC opening because h4 is an opening too, you know. Buy the latest Modern Chess Openings.
I have asked this repeatedly and the answer I get most of the time of the time by stronger players is: study tactics, tactics, tactics, endgames, and then strategy. Then when your FIDE Elo is in the 1900-2400 range, you can start looking at specific openings.
The way I go about learning/playing a new opening is I study the main lines of the opening from various books first. I also go over GM/IM games in which the opening is played, preferably heavily annotated games if I can find them. During this time I start playing the opening every chance I get online, in blitz and slower/ turn based games and even in otb rapid games. When I feel comfortable with the opening I will gradually start playing it in serious otb classic tournament games. If I find I do well with the opening I will then buy books dedicated to that particular opening...... and work more on the middlegames arising from that opening and the typical endings....
You don't. You prepare what's called an opening repertoire. It goes like this:
You pick an opening that you'll use as white. say 1.e4. Now...
The most common openings against 1.e4 are:
1...e5 - 1...c5 (sicilian defence) - 1...e6 (french defence) - 1...c6 (caro-cann defece) - 1...d5 (scandinavian/center counter defence) and a bit of a rarity 1...Nf6 (Alekhine's defence)
Now you need to figure out how you'll reply to each of those moves.
Eg. say your opponent replies with 1...e5. Your most forcing move now is 2.Nf3 thretening the e5 pawn and your opponent must defend it (well he doesn't but we take it as an axiom for now). So now your opponent has 4 ways to defend that e5 pawn which are: 2...Nc6 - 2...d6 (Philidor's defence) - 2...Bd6 [poor choice as it limits his central (d) pawn], and 2...Qe7 (even poorer choice as it blocks the movement of the king's bishop, commits the queen too early to a square which might, and indeed, probably will turn out to be a bad one for it). And so on.
Then you figure your replies to each of the most common few moves against those replies. If you start with the afore-mentioned 1.e4 and your opponent answeres 1...e5 and after that the game continues 2.Nf3 - Nc6, you're once again facing the problem as how to develop the rest of your pieces. You might want to choose 3.Bb5 (spanish opening/Ruy Lopez), 3. Bc4 (Italian game) or 3. Nc3 (3/4 knights opening) and so on until you figure out the openings that suit your individual style and needs.
As black you'll do the same. Take the four most common moves from above and find out how to reply to those. If your opponent starts with 1. e4 and you want to directly challenge him, then choose, say, the sicilian 1...c5. Now find out the most common moves against 1...c5 (2.Nf3, 2.Nc3, c3), and continue in the above mentioned fashion to build up your opening knowledge.
So in short: You don't respond correctly to 'every possible opening'. Even grandmasters don't do that (be that as it may, that their opening knowledge might not run out until move 20 or so). You pick one move to start with as white, and four moves to reply to white's first move as black. Of course white might start in 20 different ways on his first move, but on those rare occasions that he picks something other than the most used openings, you'll just have to play it by the standard opening principles and be on the lookout for tactical opportunities.
Re: my earlier post (#4)...
Lev Alburt in his Comprehensive Chess Series Vol II talks about Russians learning tactics and endgames first (common advice nowadays), then strategy, and calls openings "last and least". He says by learning to play good moves rather than play by rote as a weak player, you will be able later be able to memorize a lot of openings far faster and effortlessly than actually trying to "brute-force" (my quotes/phrase) memorize them, therefore saving precious time and brain power for more advanced sophisticated chess skill development. Something for the amateur to think about.
How do I learn to respond correctly to every possible opening?