1. A key is a collection of notes that are harmonically related to one another by reference to the harmonic series (a series of pitches relating to every pitch), for example: in the key of C, the second strongest note that sounds when you press C on a piano, is C an octave up, followed by G, D, A, E, B and F. Which gives you the seven tones of the "key" of C, in the real world, these are not the same pitches that occur when you play the white notes on a piano. Modern western music uses a system called "equal temperament", which uses maths to divide each octave evenly into 12 pitches, irrespective of what register or "key".
So, you can tell what key you are in in a number of ways, firstly by looking at how many and what notes you use. So for example, if you had the notes: B D F# G# A C and E, what key would you be in? If you put these pitches into scale order (descending/ascending by step) from any point, let's go with C: C D E F# G# A B, this generates your "scale", in this case, a 7-tone scale akin to the major/minor system of western development. if we analyse it a bit more, we end up with a pitch collection that doesn't strictly occur in the diatonic (major/minor) scale system: if we take the G# away, we end up with a scale called "C Lydian", which is a mode, and shares the same pitch collection as G Major. In this case we also have a G#, which means it can't be G major, which creates an altered scale that doesn't belong to any particular "key", using C as the "tonic" (return/home/reference tone), we end up with a C Lydian with a #5, or a "lydian augmented" scale. Anyway, this is probably getting a bit too detailed for the question posed: the answer, simply, is that you define your key by how each note relates to the "tonic", and this can be done in relation to question 2, too:
2. You can define your key by your chords (two or more notes sounding together), each note in a chord relates to each other note in a certain way. For example, a minor chord (three notes), consists of a minor third interval from the first to second note, and a major third interval from the second to third note. A major chord is the opposite (major-minor), a diminished chord is minor-minor, augmented chord is major-major. What we then have is a relationship of tension to non-tension, or release.
In a standard major key, you have a collection of 7 base triads which follow the following progression
I ii iii IV V vi vii: the upper case representing a major triad, lower case representing a minor. This applies to ALL major keys. So, in the key of C, you have: C, Dm, Em, F, G, Am, Bdim.
So, if you were to come up with a chord progression that went: F /// | Bb /// | F /// | C / Bb / ||, you could, by deductive reasoning, figure out you were in the key of "F", as that would take the place of the "I" chord. That would mean your related scale would be F major: F G A Bb C D E (F).
---
Now there's a lot more to it than that, and it gets a bit more fiddly when you introduce larger chords, or use a minor mode, but that should help (if it made sense) to begin with.
For the sake of discussion/thought, I would define a "key" as any point of tone center. For example, if I used all 12 pitches, but always referred back to F, either by playing MORE Fs than any other note, or by emphasising it in some other way, the tone center (and audible "key") would be F, also. This is a common way of doing things in rock music, trance, "post-rock" and minimalism.
Happy to help in any way I can with understanding music.