An Event is a block of memory with a particular size, which is the size of a String object. A KeyEvent is a block of memory with a size of sizeof(Event) + sizeof(int) which is 4 bytes (probably) bigger. You are storing things in a container of Event types, so each element in the container has a size of Event, and the int will ... well ... it will fall off the end into undefined behaviour territory. By storing pointers instead each element in the container will be the size of the pointer type, no matter what it is pointing to.
I have no idea what you did in order to ram those KeyEvent objects into an Event container, but whatever it was I recommend not doing it anymore!
P.S. Your phrasing suggests a Java background? In C++ "Event e;" is not a reference, it is an Event. Event & e; is a reference to an event. Event * e; is a pointer to an event; Event & e is implemented internally as a pointer in most C++ compilers but you shouldn't have to care. I e; think the closest thing in behaviour to what Java would do if you said Event e;
is std::shared_ptr<Event>