Capture cmd/command + enter events with Vue.js

Capture cmd/command + enter events with Vue.js

March 1, 2016

This post is getting old. Please use my Vue package to achieve this.

Unlike Shift/Alt/Ctrl, Mac/Apple key is not considered as a modifier key.

If you try to capture this with @keyup in Vue it won’t work.

But, if we change that to @keydown it does!

This won’t work

<div class="form-group">
	<strong>Title</strong>
	<input type="text" class="form-control" v-model="title"
		@keyup="save($event)">
</div>

This works!

<div class="form-group">
	<strong>Title</strong>
	<input type="text" class="form-control" v-model="title"
		@keydown="save($event)">
</div>

Personally tested and implemented in Vue 1.0.24