First you need to generate a key pair. (Actually for real life event processing the key parts should already be asigned to interaction subject according to application logic), ) This is the slowest part. For demonstration of concept you can start with several bytes of key lenght. Pick how large a key you want. Larger keys are more secure, but take longer to generate, and somewhat longer to use (especially decrypting the web browser entries). 512 bit key modulos (32 byte keys, ie p and q are 256 bits each) are still considered somewhat secure. My browser took about 3 minutes to generate a key of this size on my old p2-450. Try a smaller one first, like 8 bytes and square that time twice to see how long it might take for you.
Note that your browser response may be slow and you should NOT abort the script while it is taking a time to generate the keys.
2007 InstantGlobe.com, adapted from John Hanna's JS implementation and distributed under the Gnu Public License.