Keycode in close function?

Keycode in close function?


Hi,
I've got a simple little modal dialog where I want to do things based
on the OK and Cancel buttons being clicked. The button clicks work
fine; if I press RETURN or ESCAPE, my close function is called, but I
can't determine which key was pressed (my 'ev' parameter has a null
keycode). Should I be overriding something else, or am I missing
something obvious?
$('<div>Hi there!</div>').dialog({
title: 'My Title',
modal: true,
buttons: {
'OK': function() { $(this).dialog('destroy'); },
'Cancel': function() { $(this).dialog('destroy'); },
},
close:
function(ev, ui) {
$(this).dialog('destroy');
}
});