This works for the 'return' key (cos I didn't check what the code for space is):
Create a number field CountOfWords.
Create a script:
If [ Code ( Get(TriggerKeystroke) ) = 13 ]
Set Field (CountOfWords ; Wordcount(TextField )
Set the script to run OnObjectkeystroke on the text field.
I'm sure it could be tidied up a bit.
Worked perfectly thanks, code for space bar is 32