For keyboards of some nationalities, pressing the ~ key may not work- in this case, you press the ‘ key (that’s the apostrophe key, right next to the Enter key), and that should pull up the console. That’s ~, which is the key directly under the Esc key on any keyboard.
To activate the console where you input the cheat codes, you just press the ~ key at any time. PC players get a chance to muck around with Fallout 4 before they even get down to the modding- the PC version of the game comes with exclusive support for all sorts of console commands and cheatcodes, that can either swing the tides in your favor, or break the game in hilarious ways (sometimes both).