mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-23 20:06:35 +11:00
Use the ctrlKey if a MetaKey is not present. Should support Ctrl+Enter form submit on Windows.
This commit is contained in:
parent
91d40c521a
commit
9be3dea930
2 changed files with 7 additions and 2 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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">⌘ + ⏎</span>
|
<span class="shortcut">⌘+⏎ or Ctrl+⏎</span>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in a new issue