This behavior should be occurring by default, make sure you are not passing prop Keyboard false, if you are you can omit or pass it as true.
According to the documentation:
Keyboard:Boolean -> Whether support press Esc to close. Default value: true
<Modal
keyboard
title="Basic Modal"
visible={this.state.visible}
onOk={this.handleOk}
onCancel={this.handleCancel}
okButtonProps={{ disabled: true }}
cancelButtonProps={{ disabled: true }}
>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Modal>
Take a look at documentation.
– Sam