Use the ctrlKey if a MetaKey is not present. Should support Ctrl+Enter form submit on Windows.

This commit is contained in:
Martin Mahner 2013-12-17 18:19:21 +01:00
parent 91d40c521a
commit 9be3dea930
2 changed files with 7 additions and 2 deletions

View file

@ -33,7 +33,12 @@
jQuery(function($) { jQuery(function($) {
$('.autofocus textarea:first').focus(); $('.autofocus textarea:first').focus();
$('.superenter textarea').on('keydown', function(e){ $('.superenter textarea').on('keydown', function(e){
if(e.keyCode == 13 && e.metaKey) { // Windows does not have a metaKey, use ctrl instead.
// https://github.com/jquery/jquery/blob/633ca9c1610c49dbb780e565f4f1202e1fe20fae/src/event.js#L552-555
if (event.metaKey === undefined) {
event.metaKey = event.ctrlKey;
}
if (e.keyCode == 13 && e.metaKey) {
$(this).closest('form').submit(); $(this).closest('form').submit();
return false; return false;
} }

View file

@ -42,6 +42,6 @@
</div> </div>
{% endif %} {% endif %}
<input tabindex="0" type="submit"class="btn btn-primary" value="{% trans "Paste it" %}"> <input tabindex="0" type="submit"class="btn btn-primary" value="{% trans "Paste it" %}">
<span class="shortcut">&#8984; + &#9166;</span> <span class="shortcut">&#8984;+&#9166; or Ctrl+&#9166;</span>
</div> </div>
</form> </form>