From bc9867af0b5e6b5093a87ea2de16c95cf8d6cf02 Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Fri, 3 Aug 2012 21:50:12 -0700 Subject: [PATCH] change enter and delete key behaviors. fixes #295 --- select2.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/select2.js b/select2.js index 47fbf872..c0a54cce 100755 --- a/select2.js +++ b/select2.js @@ -1360,7 +1360,15 @@ return; } - if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.ESC) { + if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) + || e.which === KEY.ESC || e.which == KEY.ENTER) { + return; + } + + if (e.which == KEY.DELETE) { + if (this.opts.allowClear) { + this.clear(); + } return; } @@ -1686,7 +1694,8 @@ } } - if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) || e.which === KEY.BACKSPACE || e.which === KEY.ESC) { + if (e.which === KEY.TAB || KEY.isControl(e) || KEY.isFunctionKey(e) + || e.which === KEY.BACKSPACE || e.which === KEY.ESC || e.which === KEY.ENTER) { return; }