JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="/cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.min.js"></script>
<table>
<tr>
<td>
<select class="rp">
<option value="1">1</option>
<option value="2">2</option>
</select>
</td>
<td>
<select class="js-example-data-array"></select>
</td>
</tr>
</table>
JavaScript
$('select:first').focus();
$('input, select, textarea').on('keydown', function(e) {
if (e.which == 13) {
if (e.ctrlKey) {
$(this).closest('form').submit();
} else {
var fields = $(this).closest('form').find('input, select, textarea');
var total = fields.length;
var index = fields.index(this);
fields.eq( index + (e.shiftKey ? (index > 0 ? -1 : 0 ) : (index < total ? +1 : total ) ) ).focus();
return false;
}
}
});
var data = [{ id: 0, text: 'enhancement' }, { id: 1, text: 'bug' }, { id: 2, text: 'duplicate' }, { id: 3, text: 'invalid' }, { id: 4, text: 'wontfix' }];
$(".js-example-data-array").select2({
data: data
})